Zelda Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2023-10-15 01:58:19
Exec Total Coverage
Lines: 8432 12341 68.3%
Functions: 92 126 73.0%
Branches: 5681 10711 53.0%

Line Branch Exec Source
1 #include "allegro/file.h"
2 #include "base/util.h"
3 #include "base/zapp.h"
4 #include "base/qrs.h"
5 #include "base/cpool.h"
6 #include "base/autocombo.h"
7 #include "base/packfile.h"
8 #include "base/dmap.h"
9 #include "base/combo.h"
10 #include "base/msgstr.h"
11 #include <filesystem>
12 #include <stdio.h>
13 #include <cstring>
14 #include <string>
15 #include <map>
16 #include <vector>
17 #include <assert.h>
18 #include <fmt/format.h>
19
20
21 #include "metadata/sigs/devsig.h.sig"
22 #include "metadata/sigs/compilersig.h.sig"
23 #include "metadata/versionsig.h"
24 #include "base/zc_alleg.h"
25 #include "base/zdefs.h"
26 #include "base/colors.h"
27 #include "tiles.h"
28 #include "base/zsys.h"
29 #include "qst.h"
30 #include "defdata.h"
31 #include "subscr.h"
32 #include "font.h"
33 #include "zc/replay.h"
34 #include "zc/zc_custom.h"
35 #include "sfx.h"
36 #include "md5.h"
37 #include "zinfo.h"
38 #include "zc/ffscript.h"
39 #include "particles.h"
40 #include "dialog/alert.h"
41 #include "base/misctypes.h"
42 #include "base/initdata.h"
43
44 //FFScript FFCore;
45 extern FFScript FFCore;
46 extern ZModule zcm;
47 extern zcmodule moduledata;
48 extern uint8_t __isZQuest;
49 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
50 extern particle_list particles;
51 extern void setZScriptVersion(int32_t s_version);
52 //FFSCript FFEngine;
53
54 static bool read_ext_zinfo = false, read_zinfo = false;
55 static bool loadquest_report = false;
56 static char const* loading_qst_name = NULL;
57 static byte loading_qst_num = 0;
58 dword loading_tileset_flags = 0;
59
60 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0},combo_auto_listpos[MAX_COMBO_COLS]={0};
61 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
62
63 #ifdef _MSC_VER
64 #define strncasecmp _strnicmp
65 #endif
66
67 #ifndef _AL_MALLOC
68 #define _AL_MALLOC(a) _al_malloc(a)
69 #define _AL_FREE(a) _al_free(a)
70 #endif
71
72 using std::string;
73 using std::pair;
74
75 // extern bool debug;
76 extern int32_t hero_animation_speed; //lower is faster animation
77 extern byte *colordata;
78 //extern byte *tilebuf;
79 extern tiledata *newtilebuf;
80 extern byte *trashbuf;
81 extern itemdata *itemsbuf;
82 extern wpndata *wpnsbuf;
83 extern comboclass *combo_class_buf;
84 extern guydata *guysbuf;
85 extern ZCHEATS zcheats;
86 extern char palnames[MAXLEVELS][17];
87 extern int32_t memrequested;
88 extern char *byte_conversion(int32_t number, int32_t format);
89 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
90 string zScript;
91 115 std::map<int32_t, script_slot_data > ffcmap;
92 115 std::map<int32_t, script_slot_data > globalmap;
93 115 std::map<int32_t, script_slot_data > genericmap;
94 115 std::map<int32_t, script_slot_data > itemmap;
95 115 std::map<int32_t, script_slot_data > npcmap;
96 115 std::map<int32_t, script_slot_data > ewpnmap;
97 115 std::map<int32_t, script_slot_data > lwpnmap;
98 115 std::map<int32_t, script_slot_data > playermap;
99 115 std::map<int32_t, script_slot_data > dmapmap;
100 115 std::map<int32_t, script_slot_data > screenmap;
101 115 std::map<int32_t, script_slot_data > itemspritemap;
102 115 std::map<int32_t, script_slot_data > comboscriptmap;
103 115 std::map<int32_t, script_slot_data > subscreenmap;
104 void free_newtilebuf();
105 bool combosread=false;
106 bool mapsread=false;
107 bool fixffcs=false;
108 bool fixpolsvoice=false;
109
110 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
111 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
112 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
113 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
114
115 char qstdat_string[2048] = { 0 };
116
117 static zinfo* load_tmp_zi = NULL;
118
119 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
120 const byte clavio[9]={97,109,111,110,103,117,115,0};
121
122 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
123 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
124
125 const char *qst_error[] =
126 {
127 "OK","File not found","Invalid quest file",
128 "Version not supported","Obsolete version",
129 "Missing new data" , /* but let it pass in ZQuest */
130 "Internal error occurred", "Invalid password",
131 "Doesn't match saved game", "Save file is for older version of quest; please start new save",
132 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
133 };
134
135 //for legacy quests -DD
136 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
137 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
138 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
139 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
140 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
141 };
142
143 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
144
145
146 void delete_combo_aliases()
147 {
148 for(int32_t j(0); j<256; j++)
149 {
150 if(combo_aliases[j].combos != NULL)
151 {
152 delete[] combo_aliases[j].combos;
153 combo_aliases[j].combos=NULL;
154 }
155
156 if(combo_aliases[j].csets != NULL)
157 {
158 delete[] combo_aliases[j].csets;
159 combo_aliases[j].csets=NULL;
160 }
161 }
162
163 }
164
165 char *byte_conversion(int32_t number, int32_t format)
166 {
167 static char num_str[40];
168
169 if(format==-1) //auto
170 {
171 format=1; //bytes
172
173 if(number>1024)
174 {
175 format=2; //kilobytes
176 }
177
178 if(number>1024*1024)
179 {
180 format=3; //megabytes
181 }
182
183 if(number>1024*1024*1024)
184 {
185 format=4; //gigabytes (dude, what are you doing?)
186 }
187 }
188
189 switch(format)
190 {
191 case 1: //bytes
192 sprintf(num_str,"%db",number);
193 break;
194
195 case 2: //kilobytes
196 sprintf(num_str,"%.2fk",float(number)/1024);
197 break;
198
199 case 3: //megabytes
200 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
201 break;
202
203 case 4: //gigabytes
204 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
205 break;
206
207 default:
208 abort();
209 break;
210 }
211
212 return num_str;
213 }
214
215 1380 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
216 {
217 static char num_str1[40];
218 static char num_str2[40];
219 static char num_str[80];
220
221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1380 times.
1380 if(format1==-1) //auto
222 {
223 1380 format1=1; //bytes
224
225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1380 times.
1380 if(number1>1024)
226 {
227 1380 format1=2; //kilobytes
228 1380 }
229
230
2/2
✓ Branch 0 taken 920 times.
✓ Branch 1 taken 460 times.
1380 if(number1>1024*1024)
231 {
232 460 format1=3; //megabytes
233 460 }
234
235
1/2
✓ Branch 0 taken 1380 times.
✗ Branch 1 not taken.
1380 if(number1>1024*1024*1024)
236 {
237 format1=4; //gigabytes (dude, what are you doing?)
238 }
239 1380 }
240
241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1380 times.
1380 if(format2==-1) //auto
242 {
243 1380 format2=1; //bytes
244
245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1380 times.
1380 if(number2>1024)
246 {
247 1380 format2=2; //kilobytes
248 1380 }
249
250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1380 times.
1380 if(number2>1024*1024)
251 {
252 1380 format2=3; //megabytes
253 1380 }
254
255
1/2
✓ Branch 0 taken 1380 times.
✗ Branch 1 not taken.
1380 if(number2>1024*1024*1024)
256 {
257 format2=4; //gigabytes (dude, what are you doing?)
258 }
259 1380 }
260
261
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 920 times.
✓ Branch 3 taken 460 times.
✗ Branch 4 not taken.
1380 switch(format1)
262 {
263 case 1: //bytes
264 sprintf(num_str1,"%db",number1);
265 break;
266
267 case 2: //kilobytes
268 920 sprintf(num_str1,"%.2fk",float(number1)/1024);
269 920 break;
270
271 case 3: //megabytes
272 460 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
273 460 break;
274
275 case 4: //gigabytes
276 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
277 break;
278
279 default:
280 abort();
281 break;
282 }
283
284
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1380 times.
✗ Branch 4 not taken.
1380 switch(format2)
285 {
286 case 1: //bytes
287 sprintf(num_str2,"%db",number2);
288 break;
289
290 case 2: //kilobytes
291 sprintf(num_str2,"%.2fk",float(number2)/1024);
292 break;
293
294 case 3: //megabytes
295 1380 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
296 1380 break;
297
298 case 4: //gigabytes
299 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
300 break;
301
302 default:
303 abort();
304 break;
305 }
306
307 1380 sprintf(num_str, "%s/%s", num_str1, num_str2);
308 1380 return num_str;
309 }
310
311 char *ordinal(int32_t num)
312 {
313 static const char *ending[4] = {"st","nd","rd","th"};
314 static char ord_str[8];
315
316 char *end;
317 int32_t t=(num%100)/10;
318 int32_t n=num%10;
319
320 if(n>=1 && n<4 && t!=1)
321 end = (char *)ending[n-1];
322 else
323 end = (char *)ending[3];
324
325 sprintf(ord_str,"%d%s",num%10000,end);
326 return ord_str;
327 }
328
329 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
330 {
331 int32_t ret;
332 *version=0;
333 *build=0;
334 byte temp_map_count=map_count;
335 byte temp_midi_flags[MIDIFLAGS_SIZE];
336 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
337
338 zquestheader tempheader;
339
340 if(!f)
341 {
342 return qe_invalid;
343 }
344
345 ret=readheader(f, &tempheader);
346
347 if(ret)
348 {
349 return ret;
350 }
351
352 map_count=temp_map_count;
353 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
354 *version=tempheader.zelda_version;
355 *build=tempheader.build;
356 return 0;
357 }
358
359
360 bool find_section(PACKFILE *f, int32_t section_id_requested)
361 {
362
363 if(!f)
364 {
365 return false;
366 }
367
368 int32_t section_id_read;
369 bool catchup=false;
370 word dummy;
371 byte tempbyte;
372 char tempbuf[65536];
373
374
375 switch(section_id_requested)
376 {
377 case ID_RULES:
378 case ID_STRINGS:
379 case ID_MISC:
380 case ID_TILES:
381 case ID_COMBOS:
382 case ID_CSETS:
383 case ID_MAPS:
384 case ID_DMAPS:
385 case ID_DOORS:
386 case ID_ITEMS:
387 case ID_WEAPONS:
388 case ID_COLORS:
389 case ID_ICONS:
390 case ID_INITDATA:
391 case ID_GUYS:
392 case ID_MIDIS:
393 case ID_CHEATS:
394 break;
395
396 default:
397 al_trace("Bad section requested!\n");
398 return false;
399 break;
400 }
401
402 dword section_size;
403
404 //section id
405 if(!p_mgetl(&section_id_read,f))
406 {
407 return false;
408 }
409
410 while(!pack_feof(f))
411 {
412 switch(section_id_read)
413 {
414 case ID_RULES:
415 case ID_STRINGS:
416 case ID_MISC:
417 case ID_TILES:
418 case ID_COMBOS:
419 case ID_CSETS:
420 case ID_MAPS:
421 case ID_DMAPS:
422 case ID_DOORS:
423 case ID_ITEMS:
424 case ID_WEAPONS:
425 case ID_COLORS:
426 case ID_ICONS:
427 case ID_INITDATA:
428 case ID_GUYS:
429 case ID_MIDIS:
430 case ID_CHEATS:
431 catchup=false;
432 break;
433
434 default:
435 break;
436 }
437
438
439 while(catchup)
440 {
441 //section id
442 section_id_read=(section_id_read<<8);
443
444 if(!p_getc(&tempbyte,f))
445 {
446 return false;
447 }
448
449 section_id_read+=tempbyte;
450 }
451
452 if(section_id_read==section_id_requested)
453 {
454 return true;
455 }
456 else
457 {
458 //section version info
459 if(!p_igetw(&dummy,f))
460 {
461 return false;
462 }
463
464 if(!p_igetw(&dummy,f))
465 {
466 return false;
467 }
468
469 //section size
470 if(!p_igetl(&section_size,f))
471 {
472 return false;
473 }
474
475 //pack_fseek(f, section_size);
476 while(section_size>65535)
477 {
478 pfread(tempbuf,65535,f);
479 tempbuf[65535]=0;
480 section_size-=65535;
481 }
482
483 if(section_size>0)
484 {
485 pfread(tempbuf,section_size,f);
486 tempbuf[section_size]=0;
487 }
488 }
489
490 //section id
491 if(!p_mgetl(&section_id_read,f))
492 {
493 return false;
494 }
495 }
496
497 return false;
498 }
499
500
501
502
503
504 bool valid_zqt(PACKFILE *f)
505 {
506
507 //word tiles_used;
508 //word combos_used;
509 //open the file
510 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
511 if(!f)
512 return false;
513
514 //for now, everything else is valid
515 return true;
516
517 /*int16_t version;
518 byte build;
519
520 //read the version and make sure it worked
521 if(!p_igetw(&version,f))
522 {
523 goto error;
524 }
525
526 //read the build and make sure it worked
527 if(!p_getc(&build,f))
528 goto error;
529
530 //read the tile info and make sure it worked
531 if(!p_igetw(&tiles_used,f))
532 {
533 goto error;
534 }
535
536 for (int32_t i=0; i<tiles_used; i++)
537 {
538 if(!pfread(trashbuf,tilesize(tf4Bit),f))
539 {
540 goto error;
541 }
542 }
543
544 //read the combo info and make sure it worked
545 if(!p_igetw(&combos_used,f))
546 {
547 goto error;
548 }
549 for (int32_t i=0; i<combos_used; i++)
550 {
551 if(!pfread(trashbuf,sizeof(newcombo),f))
552 {
553 goto error;
554 }
555 }
556
557 //read the palette info and make sure it worked
558 for (int32_t i=0; i<48; i++)
559 {
560 if(!pfread(trashbuf,newpdTOTAL,f))
561 {
562 goto error;
563 }
564 }
565 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
566 {
567 goto error;
568 }
569 for (int32_t i=0; i<MAXLEVELS; i++)
570 {
571 if(!pfread(trashbuf,PALNAMESIZE,f))
572 {
573 goto error;
574 }
575 }
576
577 //read the sprite info and make sure it worked
578 for (int32_t i=0; i<MAXITEMS; i++)
579 {
580 if(!pfread(trashbuf,sizeof(itemdata),f))
581 {
582 goto error;
583 }
584 }
585
586 for (int32_t i=0; i<MAXWPNS; i++)
587 {
588 if(!pfread(trashbuf,sizeof(wpndata),f))
589 {
590 goto error;
591 }
592 }
593
594 //read the triforce pieces info and make sure it worked
595 for (int32_t i=0; i<8; ++i)
596 {
597 if(!p_getc(&trashbuf,f))
598 {
599 goto error;
600 }
601 }
602
603
604
605 //read the game icons info and make sure it worked
606 for (int32_t i=0; i<4; ++i)
607 {
608 if(!p_igetw(&trashbuf,f))
609 {
610 goto error;
611 }
612 }
613
614 //read the misc colors info and map styles info and make sure it worked
615 if(!pfread(trashbuf,sizeof(zcolors),f))
616 {
617 goto error;
618 }
619
620 //read the template screens and make sure it worked
621 byte num_maps;
622 if(!p_getc(&num_maps,f))
623 {
624 goto error;
625 }
626 for (int32_t i=0; i<TEMPLATES; i++)
627 {
628 if(!pfread(trashbuf,sizeof(mapscr),f))
629 {
630 goto error;
631 }
632 }
633 if (num_maps>1) //dungeon templates
634 {
635 for (int32_t i=0; i<TEMPLATES; i++)
636 {
637 if(!pfread(trashbuf,sizeof(mapscr),f))
638 {
639 goto error;
640 }
641 }
642 }
643
644 //yay! it worked! close the file and say everything was ok.
645 pack_fclose(f);
646 return true;
647
648 error:
649 pack_fclose(f);
650 return false;*/
651 }
652
653 bool valid_zqt(const char *filename)
654 {
655 PACKFILE *f=NULL;
656 bool isvalid;
657 int32_t error;
658 f=open_quest_file(&error, filename, false);
659
660 if(!f)
661 {
662 // setPackfilePassword(NULL);
663 return false;
664 }
665
666 isvalid=valid_zqt(f);
667
668 clear_quest_tmpfile();
669 pack_fclose(f);
670
671 // setPackfilePassword(NULL);
672 return isvalid;
673 }
674
675 /*
676 .qst file history
677
678 .qst files have always been compressed using allegro's packfiles.
679
680 At some point, an encoding layer was added. The two layers look like this:
681
682 1) The top layer is from us. See decode_file_007.
683 [0-24] Preamble "Zelda Classic Quest File"
684 [25-28] Initial decoding seed value.
685 [29-X] Allegro-compressed payload (AKA "packed" file), but XOR'd based on seed value
686 [last 4] Checksum
687
688 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
689 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
690 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
691 The oldest quests skip the password part.
692
693 Simply, the job of this function is to peel away the top layer.
694
695 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
696 in opening and saving files. There is no version field, so they decryption key is
697 found via trial-by-error (very slow!)
698
699 There are other file types of interest:
700 - .zqt: quest template files, skips top-layer encryption pass
701 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
702 - .qu?: same as above. automated backup files
703 - .qb?: same as above. automated backup files
704 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
705
706 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
707 files are now "slh!.AG ZC Enhanced Quest File".
708 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
709 */
710 128 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
711 {
712
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if (show_progress)
713 {
714 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
715 }
716
717 128 auto unencrypted_result = try_open_maybe_legacy_encoded_file(filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
718
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 3 times.
128 if (unencrypted_result.decoded_pf)
719 125 return unencrypted_result.decoded_pf;
720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (unencrypted_result.not_found)
721 {
722 *open_error = qe_notfound;
723 return nullptr;
724 }
725
726 // Everything below here is legacy code - recently saved quest files will have
727 // returned by now.
728 // The only replay qst file that is still using this legacy encoding is `link_to_the_zelda.qst`.
729
730 // Note: although this is primarily for loading .qst files, it can also handle all of the
731 // file types mentioned in the comment above. No need to be told if the file being loaded
732 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
733 3 bool top_layer_compressed = unencrypted_result.top_layer_compressed;
734 3 bool compressed = unencrypted_result.compressed;
735 3 bool encrypted = unencrypted_result.encrypted;
736
737 char tmpfilename[L_tmpnam];
738 3 temp_name(tmpfilename);
739 char percent_done[30];
740 3 int32_t current_method=0;
741
742 PACKFILE *f;
743 3 const char *passwd= encrypted ? datapwd : "";
744
745 // oldquest flag is set when an unencrypted qst file is suspected.
746 3 bool oldquest = false;
747 int32_t ret;
748
749
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(strcmp(filename, "default.qst")!=0)
750 {
751 3 box_out(filename);
752 3 }
753 else
754 {
755 box_out("new quest"); // Or whatever
756 }
757 3 box_out("...");
758 3 box_eol();
759 3 box_eol();
760
761
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(encrypted)
762 {
763 3 box_out("Decrypting...");
764 3 box_save_x();
765 3 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
766
767
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(ret)
768 {
769 switch(ret)
770 {
771 case 1:
772 box_out("error.");
773 box_eol();
774 box_end(true);
775 *open_error=qe_notfound;
776 return NULL;
777
778 case 2:
779 box_out("error.");
780 box_eol();
781 box_end(true);
782 *open_error=qe_internal;
783 return NULL;
784 // be sure not to delete tmpfilename now...
785 }
786
787 if(ret==5) //old encryption?
788 {
789 current_method++;
790 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
791 box_out(percent_done);
792 box_load_x();
793 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
794 }
795
796 if(ret==5) //old encryption?
797 {
798 current_method++;
799 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
800 box_out(percent_done);
801 box_load_x();
802 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
803 }
804
805 if(ret==5) //old encryption?
806 {
807 current_method++;
808 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
809 box_out(percent_done);
810 box_load_x();
811 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
812 }
813
814 if(ret==5) //old encryption?
815 {
816 current_method++;
817 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
818 box_out(percent_done);
819 box_load_x();
820 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
821 }
822
823 if(ret)
824 {
825 oldquest = true;
826 passwd="";
827 }
828 }
829
830 3 box_out("okay.");
831 3 box_eol();
832 3 }
833 else
834 {
835 oldquest = true;
836 }
837
838 3 box_out("Opening...");
839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
840
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!f)
841 {
842 if((compressed==1)&&(errno==EDOM))
843 {
844 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
845 }
846
847 if(!f)
848 {
849 if(!oldquest)
850 {
851 delete_file(tmpfilename);
852 }
853 box_out("error.");
854 box_eol();
855 box_end(true);
856 *open_error=qe_invalid;
857 return NULL;
858 }
859 }
860
861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!oldquest)
862 {
863 3 delete_file(tmpfilename);
864 3 }
865
866 3 box_out("okay.");
867 3 box_eol();
868
869 3 return f;
870 128 }
871
872 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
873 {
874 char *filename;
875 PACKFILE *f=NULL;
876 int32_t open_error=0;
877
878 strcpy(qstdat_string, "modules/classic/default.qst");
879 if(Header->templatepath[0]==0)
880 {
881 filename=(char *)malloc(2048);
882 strcpy(filename, qstdat_string);
883 }
884 else
885 {
886 // TODO: should be safe to remove this, no one seems to use custom quest templates.
887 filename=Header->templatepath;
888 }
889
890 f=open_quest_file(&open_error, filename, false);
891
892 if(Header->templatepath[0]==0)
893 {
894 free(filename);
895 }
896
897 if(!f)
898 {
899 return NULL;
900 }
901
902 if(validate)
903 {
904 if(!valid_zqt(f))
905 {
906 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
907 pack_fclose(f);
908 clear_quest_tmpfile();
909 return NULL;
910 }
911 }
912
913 return f;
914 }
915
916 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
917 {
918 // We absolutely do not support loading from a template file to initialize data outside the editor.
919 // TODO: move this code into zq/
920 if (get_app_id() != App::zquest) return false;
921
922 combosread=false;
923 mapsread=false;
924 fixffcs=false;
925
926 switch(section_id)
927 {
928 case ID_RULES:
929 case ID_STRINGS:
930 case ID_MISC:
931 case ID_TILES:
932 case ID_COMBOS:
933 case ID_CSETS:
934 case ID_MAPS:
935 case ID_DMAPS:
936 case ID_DOORS:
937 case ID_ITEMS:
938 case ID_WEAPONS:
939 case ID_COLORS:
940 case ID_ICONS:
941 case ID_INITDATA:
942 case ID_GUYS:
943 case ID_MIDIS:
944 case ID_CHEATS:
945 case ID_ITEMDROPSETS:
946 case ID_FAVORITES:
947 break;
948
949 default:
950 return false;
951 break;
952 }
953
954 int32_t ret;
955 word version, build;
956 PACKFILE *f=NULL;
957
958 char deletefilename[1024];
959 deletefilename[0]=0;
960
961 //why is this here?
962 /*
963 if(colordata==NULL)
964 return false;
965 */
966
967 //setPackfilePassword(datapwd);
968 f=open_quest_template(Header, deletefilename, validate);
969
970 if(!f) //no file, nothing to delete
971 {
972 // setPackfilePassword(NULL);
973 return false;
974 }
975
976 ret=get_version_and_build(f, &version, &build);
977
978 if(ret||(version==0))
979 {
980 pack_fclose(f);
981 clear_quest_tmpfile();
982
983 if(deletefilename[0])
984 {
985 delete_file(deletefilename);
986 }
987
988 // setPackfilePassword(NULL);
989 return false;
990 }
991
992 if(!find_section(f, section_id))
993 {
994 al_trace("Can't find section!\n");
995 pack_fclose(f);
996 clear_quest_tmpfile();
997
998 if(deletefilename[0])
999 {
1000 delete_file(deletefilename);
1001 }
1002
1003 //setPackfilePassword(NULL);
1004 return false;
1005 }
1006
1007 switch(section_id)
1008 {
1009 case ID_RULES:
1010 //rules
1011 ret=readrules(f, Header);
1012 break;
1013
1014 case ID_STRINGS:
1015 //strings
1016 ret=readstrings(f, Header);
1017 break;
1018
1019 case ID_MISC:
1020 //misc data
1021 ret=readmisc(f, Header, Misc);
1022 break;
1023
1024 case ID_TILES:
1025 //tiles
1026 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1027 break;
1028
1029 case ID_COMBOS:
1030 //combos
1031 clear_combos();
1032 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1033 combosread=true;
1034 break;
1035
1036 case ID_COMBOALIASES:
1037 //combos
1038 ret=readcomboaliases(f, Header, version, build);
1039 break;
1040
1041 case ID_CSETS:
1042 //color data
1043 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1044 break;
1045
1046 case ID_MAPS:
1047 //maps
1048 ret=readmaps(f, Header);
1049 mapsread=true;
1050 break;
1051
1052 case ID_DMAPS:
1053 //dmaps
1054 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1055 break;
1056
1057 case ID_DOORS:
1058 //door combo sets
1059 ret=readdoorcombosets(f, Header);
1060 break;
1061
1062 case ID_ITEMS:
1063 //items
1064 ret=readitems(f, version, build);
1065 break;
1066
1067 case ID_WEAPONS:
1068 //weapons
1069 ret=readweapons(f, Header);
1070 break;
1071
1072 case ID_COLORS:
1073 //misc. colors
1074 ret=readmisccolors(f, Header, Misc);
1075 break;
1076
1077 case ID_ICONS:
1078 //game icons
1079 ret=readgameicons(f, Header, Misc);
1080 break;
1081
1082 case ID_INITDATA:
1083 //initialization data
1084 ret=readinitdata(f, Header);
1085 break;
1086
1087 case ID_GUYS:
1088 //guys
1089 ret=readguys(f, Header);
1090 break;
1091
1092 case ID_MIDIS:
1093 //midis
1094 ret=readtunes(f, Header, tunes);
1095 break;
1096
1097 case ID_CHEATS:
1098 //cheat codes
1099 ret=readcheatcodes(f, Header);
1100 break;
1101
1102 case ID_ITEMDROPSETS:
1103 //item drop sets
1104 // Why is this one commented out?
1105 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1106 break;
1107
1108 case ID_FAVORITES:
1109 // favorite combos and aliases
1110 ret=readfavorites(f, version, build);
1111 break;
1112
1113 default:
1114 ret=-1;
1115 break;
1116 }
1117
1118 pack_fclose(f);
1119 clear_quest_tmpfile();
1120
1121 if(deletefilename[0])
1122 {
1123 delete_file(deletefilename);
1124 }
1125
1126 //setPackfilePassword(NULL);
1127 if(!ret)
1128 {
1129 return true;
1130 }
1131
1132 return false;
1133 }
1134
1135 bool init_tiles(bool validate, zquestheader *Header)
1136 {
1137 return init_section(Header, ID_TILES, NULL, NULL, validate);
1138 }
1139
1140 bool init_combos(bool validate, zquestheader *Header)
1141 {
1142 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1143 }
1144
1145 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1146 {
1147 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1148 }
1149
1150 128 void init_spritelists()
1151 {
1152
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 35 times.
128 if(FFCore.quest_format[vZelda] < 0x255)
1153 {
1154 93 guys.setMax(255);
1155 93 items.setMax(255);
1156 93 Ewpns.setMax(255);
1157 93 Lwpns.setMax(255);
1158 93 chainlinks.setMax(255);
1159 93 decorations.setMax(255);
1160 93 particles.setMax(255);
1161 93 }
1162 else
1163 {
1164 35 guys.setMax(255);
1165 35 items.setMax(255);
1166 35 Ewpns.setMax(255);
1167 35 Lwpns.setMax(255);
1168 35 chainlinks.setMax(255);
1169 35 decorations.setMax(255);
1170 35 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1171 }
1172 128 }
1173
1174 115 bool reset_items(bool validate, zquestheader *Header)
1175 {
1176 115 bool ret = true;
1177
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if (get_app_id() == App::zquest)
1178 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1179
1180
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 29440 times.
29555 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1181
1182 115 return ret;
1183 }
1184
1185 bool reset_guys()
1186 {
1187 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1188 init_guys(V_GUYS);
1189 return true;
1190 }
1191
1192 bool reset_wpns(bool validate, zquestheader *Header)
1193 {
1194 bool ret = true;
1195 if (get_app_id() == App::zquest)
1196 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1197
1198 for(int32_t i=0; i<MAXWPNS; i++)
1199 reset_weaponname(i);
1200
1201 return ret;
1202 }
1203
1204 bool reset_mapstyles(bool validate, miscQdata *Misc)
1205 {
1206 Misc->colors.blueframe_tile = 20044;
1207 Misc->colors.blueframe_cset = 0;
1208 Misc->colors.triforce_tile = 23461;
1209 Misc->colors.triforce_cset = 1;
1210 Misc->colors.triframe_tile = 18752;
1211 Misc->colors.triframe_cset = 1;
1212 Misc->colors.overworld_map_tile = 16990;
1213 Misc->colors.overworld_map_cset = 2;
1214 Misc->colors.HCpieces_tile = 21160;
1215 Misc->colors.HCpieces_cset = 8;
1216 Misc->colors.dungeon_map_tile = 19651;
1217 Misc->colors.dungeon_map_cset = 8;
1218 return true;
1219 }
1220
1221 115 int32_t get_qst_buffers()
1222 {
1223 115 memrequested+=(sizeof(mapscr)*MAPSCRS);
1224 115 Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
1225 115 TheMaps.resize(MAPSCRS);
1226 115 map_autolayers.resize(6);
1227
1228
2/2
✓ Branch 0 taken 15640 times.
✓ Branch 1 taken 115 times.
15755 for(int32_t i(0); i<MAPSCRS; i++)
1229 15640 TheMaps[i].zero_memory();
1230
1231 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1232 115 Z_message("OK\n");
1233
1234 // Allocating space for all 65535 strings uses up 10.62MB...
1235 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1236 // (Shoelace's "Hero of Dreams" uses 1415.)
1237 // So let's be a bit generous and allow 4096 initially.
1238 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1239 // I tested it and it worked without flaw on 6/6/11. - L.
1240 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1241 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1242 // See https://discord.com/channels/876899628556091432/992984989073416242
1243 115 msg_strings_size = 8192;
1244 115 memrequested+=(sizeof(MsgStr)*msg_strings_size);
1245 115 Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));
1246
1247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 MsgStrings = new MsgStr[msg_strings_size];
1248
1249 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1250
2/2
✓ Branch 0 taken 942080 times.
✓ Branch 1 taken 115 times.
942195 for(auto q = 0; q < msg_strings_size; ++q)
1251 {
1252 942080 MsgStrings[q].clear();
1253 942080 }
1254 115 Z_message("OK\n"); // Allocating string buffer...
1255
1256 115 memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
1257 115 Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));
1258
1259
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1260 return 0;
1261
1262 115 Z_message("OK\n"); // Allocating door combo buffer...
1263
1264 115 memrequested+=(sizeof(dmap)*MAXDMAPS);
1265 115 Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));
1266
1267
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if((DMaps=new dmap[MAXDMAPS])==NULL)
1268 return 0;
1269
1270 115 Z_message("OK\n"); // Allocating dmap buffer...
1271
1272 115 memrequested+=(sizeof(newcombo)*MAXCOMBOS);
1273 115 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
1274
1275 115 combobuf.clear();
1276 115 combobuf.resize(MAXCOMBOS);
1277 115 Z_message("OK\n"); // Allocating combo buffer...
1278
1279 115 memrequested+=(psTOTAL255);
1280 115 Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));
1281
1282
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1283 return 0;
1284
1285 115 Z_message("OK\n"); // Allocating color data buffer...
1286
1287 115 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1288 115 Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));
1289
1290 115 free_newtilebuf();
1291
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1292 return 0;
1293
1294 115 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1295 //Z_message("Performed memset on tiles\n");
1296 115 clear_tiles(newtilebuf);
1297 //Z_message("Performed clear_tiles()\n");
1298 115 Z_message("OK\n"); // Allocating tile buffer...
1299
1300
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(is_editor())
1301 {
1302 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1303 Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));
1304
1305 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1306 return 0;
1307
1308 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1309 clear_tiles(grabtilebuf);
1310 Z_message("OK\n"); // Allocating tile grab buffer...
1311 }
1312
1313 115 memrequested+=(100000);
1314 115 Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));
1315
1316
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if((trashbuf=(byte*)malloc(100000))==NULL)
1317 return 0;
1318
1319 115 Z_message("OK\n"); // Allocating trash buffer...
1320
1321 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1322 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1323 // fixed by ensuring there's actually itemdata there.
1324 // If you change this, be sure to update del_qst_buffers, too.
1325
1326 115 memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
1327 115 Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));
1328
1329
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1330 return 0;
1331
1332 115 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1333 115 itemsbuf++;
1334 115 Z_message("OK\n"); // Allocating item buffer...
1335
1336 115 memrequested+=(sizeof(wpndata)*MAXWPNS);
1337 115 Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));
1338
1339
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1340 return 0;
1341
1342 115 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1343 115 Z_message("OK\n"); // Allocating weapon buffer...
1344
1345 115 memrequested+=(sizeof(guydata)*MAXGUYS);
1346 115 Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));
1347
1348
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1349 return 0;
1350
1351 115 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1352 115 Z_message("OK\n"); // Allocating guy buffer...
1353
1354 115 memrequested+=(sizeof(comboclass)*cMAX);
1355 115 Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));
1356
1357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1358 return 0;
1359
1360 115 Z_message("OK\n"); // Allocating combo class buffer...
1361
1362 115 return 1;
1363 115 }
1364
1365
1366 115 void free_newtilebuf()
1367 {
1368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(newtilebuf)
1369 {
1370 for(int32_t i=0; i<NEWMAXTILES; i++)
1371 if(newtilebuf[i].data)
1372 free(newtilebuf[i].data);
1373
1374 free(newtilebuf);
1375 newtilebuf = 0;
1376 }
1377 115 }
1378
1379 void free_grabtilebuf()
1380 {
1381 if(is_editor())
1382 {
1383 if(grabtilebuf)
1384 {
1385 for(int32_t i=0; i<NEWMAXTILES; i++)
1386 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1387
1388 free(grabtilebuf);
1389 grabtilebuf = 0;
1390 }
1391 }
1392 }
1393
1394 void del_qst_buffers()
1395 {
1396 if(MsgStrings) delete[] MsgStrings;
1397
1398 if(DoorComboSets) free(DoorComboSets);
1399
1400 if (DMaps) delete[] DMaps;
1401
1402 combobuf.clear();
1403
1404 if(colordata) free(colordata);
1405
1406 free_newtilebuf();
1407 free_grabtilebuf();
1408
1409 if(trashbuf) free(trashbuf);
1410
1411 // See get_qst_buffers
1412 if(itemsbuf)
1413 {
1414 itemsbuf--;
1415 free(itemsbuf);
1416 }
1417
1418 if(wpnsbuf) free(wpnsbuf);
1419
1420 if(guysbuf) free(guysbuf);
1421
1422 if(combo_class_buf) free(combo_class_buf);
1423 }
1424
1425 4 bool init_palnames()
1426 {
1427 // if(palnames==NULL)
1428 // return false;
1429
1430
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t x=0; x<MAXLEVELS; x++)
1431 {
1432
4/4
✓ Branch 0 taken 2036 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
2048 switch(x)
1433 {
1434 case 0:
1435 4 sprintf(palnames[x],"Overworld");
1436 4 break;
1437
1438 case 10:
1439 4 sprintf(palnames[x],"Caves");
1440 4 break;
1441
1442 case 11:
1443 4 sprintf(palnames[x],"Passageways");
1444 4 break;
1445
1446 default:
1447 2036 sprintf(palnames[x],"%c",0);
1448 2036 break;
1449 }
1450 2048 }
1451
1452 4 return true;
1453 }
1454
1455 25208 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1456 {
1457 void *p;
1458
1459
1/2
✓ Branch 0 taken 25208 times.
✗ Branch 1 not taken.
25208 p = _AL_MALLOC(MAX(size, alloc_size));
1460
1461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25208 times.
25208 if(!p)
1462 {
1463 return NULL;
1464 }
1465
1466
1/2
✓ Branch 0 taken 25208 times.
✗ Branch 1 not taken.
25208 if(!pfread(p,size,f))
1467 {
1468 _AL_FREE(p);
1469 return NULL;
1470 }
1471
1472
1/2
✓ Branch 0 taken 25208 times.
✗ Branch 1 not taken.
25208 if(pack_ferror(f))
1473 {
1474 _AL_FREE(p);
1475 return NULL;
1476 }
1477
1478 25208 return p;
1479 25208 }
1480
1481 // Only use for reading parts of older quests (Header->zelda_version <= 0x192)
1482 static const byte* legacy_skip_flags;
1483
1484 /* read_midi:
1485 * Reads MIDI data from a datafile (this is not the same thing as the
1486 * standard midi file format).
1487 */
1488
1489 2301 static MIDI *read_midi(PACKFILE *f)
1490 {
1491 MIDI *m;
1492 int32_t c;
1493 2301 int16_t divisions=0;
1494 2301 int32_t len=0;
1495
1496 2301 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1497
1498
1/2
✓ Branch 0 taken 2301 times.
✗ Branch 1 not taken.
2301 if(!m)
1499 {
1500 return NULL;
1501 }
1502
1503
2/2
✓ Branch 0 taken 73632 times.
✓ Branch 1 taken 2301 times.
75933 for(c=0; c<MIDI_TRACKS; c++)
1504 {
1505 73632 m->track[c].len = 0;
1506 73632 m->track[c].data = NULL;
1507 73632 }
1508
1509 2301 p_mgetw(&divisions,f);
1510 2301 m->divisions=divisions;
1511
1512
2/2
✓ Branch 0 taken 73632 times.
✓ Branch 1 taken 2301 times.
75933 for(c=0; c<MIDI_TRACKS; c++)
1513 {
1514 73632 p_mgetl(&len,f);
1515 73632 m->track[c].len=len;
1516
1517
2/2
✓ Branch 0 taken 48424 times.
✓ Branch 1 taken 25208 times.
73632 if(m->track[c].len > 0)
1518 {
1519 25208 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1520
1521
1/2
✓ Branch 0 taken 25208 times.
✗ Branch 1 not taken.
25208 if(!m->track[c].data)
1522 {
1523 destroy_midi(m);
1524 return NULL;
1525 }
1526 25208 }
1527 73632 }
1528
1529 LOCK_DATA(m, sizeof(MIDI));
1530
1531
2/2
✓ Branch 0 taken 73632 times.
✓ Branch 1 taken 2301 times.
75933 for(c=0; c<MIDI_TRACKS; c++)
1532 {
1533
2/2
✓ Branch 0 taken 25208 times.
✓ Branch 1 taken 48424 times.
73632 if(m->track[c].data)
1534 {
1535 LOCK_DATA(m->track[c].data, m->track[c].len);
1536 25208 }
1537 73632 }
1538
1539 2301 return m;
1540 2301 }
1541
1542 void clear_combo(int32_t i)
1543 {
1544 combobuf[i].clear();
1545 }
1546
1547 void clear_combos()
1548 {
1549 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1550 clear_combo(tmpcounter);
1551 }
1552
1553 void pack_combos()
1554 {
1555 int32_t di = 0;
1556
1557 for(int32_t si=0; si<1024; si+=2)
1558 combobuf[di++] = combobuf[si];
1559
1560 for(; di<1024; di++)
1561 clear_combo(di);
1562 }
1563
1564 128 void reset_tunes(zctune *tune)
1565 {
1566
2/2
✓ Branch 0 taken 32256 times.
✓ Branch 1 taken 128 times.
32384 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1567 {
1568 32256 tune[i].reset();
1569 32256 }
1570 128 }
1571
1572
1573 /*void reset_midi(zcmidi_ *m)
1574 {
1575 m->title[0]=0;
1576 m->loop=1;
1577 m->volume=144;
1578 m->start=0;
1579 m->loop_start=-1;
1580 m->loop_end=-1;
1581 if(m->midi)
1582 {
1583 destroy_midi(m->midi);
1584 }
1585 m->midi=NULL;
1586 }
1587
1588
1589 void reset_midis(zcmidi_ *m)
1590 {
1591 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1592 {
1593 reset_midi(m+i);
1594 }
1595 }
1596 */
1597
1598 void reset_scr(int32_t scr)
1599 {
1600 /*
1601 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1602 for(unsigned i=0; i<sizeof(mapscr); i++)
1603 *(di++) = 0;
1604 TheMaps[scr].valid=mVERSION;
1605 */
1606
1607 TheMaps[scr].zero_memory();
1608 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1609
1610 for(int32_t i=0; i<6; i++)
1611 {
1612 //these will be uncommented later
1613 //TheMaps[scr].layerxsize[i]=16;
1614 //TheMaps[scr].layerysize[i]=11;
1615 TheMaps[scr].layeropacity[i]=255;
1616 }
1617
1618 TheMaps[scr].valid=mVERSION;
1619
1620 }
1621
1622 /* For reference:
1623
1624 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1625 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1626 */
1627
1628 3574 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1629 {
1630
2/2
✓ Branch 0 taken 16422 times.
✓ Branch 1 taken 1606 times.
18028 for(int32_t i=0; i<9; i++)
1631 {
1632
2/2
✓ Branch 0 taken 88692 times.
✓ Branch 1 taken 14454 times.
103146 for(int32_t j=0; j<6; j++)
1633 {
1634
2/2
✓ Branch 0 taken 28908 times.
✓ Branch 1 taken 59784 times.
88692 if(j<4)
1635 {
1636
2/2
✓ Branch 0 taken 57816 times.
✓ Branch 1 taken 1968 times.
59784 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1637 {
1638 1968 return false;
1639 }
1640
1641
1/2
✓ Branch 0 taken 57816 times.
✗ Branch 1 not taken.
57816 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1642 {
1643 return false;
1644 }
1645
1646
1/2
✓ Branch 0 taken 57816 times.
✗ Branch 1 not taken.
57816 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1647 {
1648 return false;
1649 }
1650
1651
1/2
✓ Branch 0 taken 57816 times.
✗ Branch 1 not taken.
57816 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1652 {
1653 return false;
1654 }
1655 57816 }
1656
1657
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1658 {
1659 return false;
1660 }
1661
1662
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1663 {
1664 return false;
1665 }
1666
1667
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1668 {
1669 return false;
1670 }
1671
1672
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1673 {
1674 return false;
1675 }
1676 86724 }
1677
1678
2/2
✓ Branch 0 taken 11242 times.
✓ Branch 1 taken 3212 times.
14454 if(i<2)
1679 {
1680
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.flags[i]!=b.flags[i])
1681 {
1682 return false;
1683 }
1684
1685
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1686 {
1687 return false;
1688 }
1689
1690
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1691 {
1692 return false;
1693 }
1694
1695
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1696 {
1697 return false;
1698 }
1699
1700
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1701 {
1702 return false;
1703 }
1704 3212 }
1705
1706
2/2
✓ Branch 0 taken 9636 times.
✓ Branch 1 taken 4818 times.
14454 if(i<3)
1707 {
1708
1/2
✓ Branch 0 taken 4818 times.
✗ Branch 1 not taken.
4818 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1709 {
1710 return false;
1711 }
1712
1713
1/2
✓ Branch 0 taken 4818 times.
✗ Branch 1 not taken.
4818 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1714 {
1715 return false;
1716 }
1717
1718
1/2
✓ Branch 0 taken 4818 times.
✗ Branch 1 not taken.
4818 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1719 {
1720 return false;
1721 }
1722
1723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4818 times.
4818 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1724 {
1725 return false;
1726 }
1727 4818 }
1728
1729
1/2
✓ Branch 0 taken 14454 times.
✗ Branch 1 not taken.
14454 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1730 {
1731 return false;
1732 }
1733
1734
1/2
✓ Branch 0 taken 14454 times.
✗ Branch 1 not taken.
14454 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1735 {
1736 return false;
1737 }
1738 14454 }
1739
1740 1606 return true;
1741 3574 }
1742
1743 int32_t doortranslations_u[9][4]=
1744 {
1745 {37,38,53,54},
1746 {37,38,39,40},
1747 {37,38,55,56},
1748 {37,38,39,40},
1749 {37,38,53,54},
1750 {37,38,53,54},
1751 {37,38,53,54},
1752 {7,8,23,24},
1753 {7,8,41,42}
1754 };
1755
1756 int32_t doortranslations_d[9][4]=
1757 {
1758 {117,118,133,134},
1759 {135,136,133,134},
1760 {119,120,133,134},
1761 {135,136,133,134},
1762 {117,118,133,134},
1763 {117,118,133,134},
1764 {117,118,133,134},
1765 {151,152,167,168},
1766 {137,138,167,168},
1767 };
1768
1769 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1770 int32_t doortranslations_l[9][6]=
1771 {
1772 {66,67,82,83,98,99},
1773 {66,68,82,84,98,100},
1774 {66,69,82,85,98,101},
1775 {66,68,82,84,98,100},
1776 {66,67,82,83,98,99},
1777 {66,67,82,83,98,99},
1778 {66,67,82,83,98,99},
1779 {64,65,80,81,96,97},
1780 {64,65,80,114,96,97},
1781 };
1782
1783 int32_t doortranslations_r[9][6]=
1784 {
1785
1786 {76,77,92,93,108,109},
1787 {75,77,91,93,107,109},
1788 {74,77,90,93,106,109},
1789 {75,77,91,93,107,109},
1790 {76,77,92,93,108,109},
1791 {76,77,92,93,108,109},
1792 {76,77,92,93,108,109},
1793 {78,79,94,95,110,111},
1794 {78,79,125,95,110,111},
1795 };
1796
1797 314668 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1798 {
1799 314668 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1800 }
1801
1802 308180 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1803 {
1804 //these are here to bypass compiler warnings about unused arguments
1805 308180 map=map;
1806 308180 scr=scr;
1807 308180 pos=pos;
1808
1809 //what does this function do?
1810 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1811 308180 return 2;
1812 }
1813
1814 7072 int32_t MakeDoors(int32_t map, int32_t scr)
1815 {
1816
2/2
✓ Branch 0 taken 5450 times.
✓ Branch 1 taken 1622 times.
7072 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1817 {
1818 5450 return 0;
1819 }
1820
1821 DoorComboSet tempdcs;
1822 1622 memset(&tempdcs, 0, sizeof(DoorComboSet));
1823
1824 //up
1825
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1826 {
1827
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1828 {
1829 58392 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1830 58392 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1831 58392 }
1832 14598 }
1833
1834 1622 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1835 1622 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1836 1622 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1837 1622 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1838 1622 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1839 1622 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1840
1841 //down
1842
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1843 {
1844
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1845 {
1846 58392 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1847 58392 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1848 58392 }
1849 14598 }
1850
1851 1622 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1852
1853 1622 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1854 1622 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1855 1622 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1856 1622 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1857 1622 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1858
1859 //left
1860 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1861
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1862 {
1863
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
1864 {
1865 87588 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1866 87588 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1867 87588 }
1868 14598 }
1869
1870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
1871 {
1872 if((j!=2)&&(j!=3))
1873 {
1874 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1875 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1876 }
1877 }
1878
1879 1622 tempdcs.bombdoorcombo_l[0]=0;
1880 1622 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1881 1622 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1882 1622 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1883 1622 tempdcs.bombdoorcombo_l[2]=0;
1884 1622 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1885 1622 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1886 1622 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1887
1888 //right
1889
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1890 {
1891
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
1892 {
1893 87588 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1894 87588 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1895 87588 }
1896 14598 }
1897
1898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
1899 {
1900 if((j!=2)&&(j!=3))
1901 {
1902 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1903 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1904 }
1905 }
1906
1907 1622 tempdcs.bombdoorcombo_r[0]=0;
1908 1622 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1909 1622 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1910 1622 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1911 1622 tempdcs.bombdoorcombo_r[2]=0;
1912 1622 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1913 1622 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1914 1622 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1915
1916 int32_t k;
1917
1918
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 3574 times.
3590 for(k=0; k<door_combo_set_count; k++)
1919 {
1920
2/2
✓ Branch 0 taken 1606 times.
✓ Branch 1 taken 1968 times.
3574 if(DoorComboSets[k]==tempdcs)
1921 {
1922 1606 break;
1923 }
1924 1968 }
1925
1926
2/2
✓ Branch 0 taken 1606 times.
✓ Branch 1 taken 16 times.
1622 if(k==door_combo_set_count)
1927 {
1928 16 DoorComboSets[k]=tempdcs;
1929 16 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
1930 16 ++door_combo_set_count;
1931 16 }
1932
1933 1622 return k;
1934 /*
1935 doorcombo_u[9][4];
1936 doorcset_u[9][4];
1937 doorcombo_d[9][4];
1938 doorcset_d[9][4];
1939 doorcombo_l[9][6];
1940 doorcset_l[9][6];
1941 doorcombo_r[9][6];
1942 doorcset_r[9][6];
1943 bombdoorcombo_u[2];
1944 bombdoorcset_u[2];
1945 bombdoorcombo_d[2];
1946 bombdoorcset_d[2];
1947 bombdoorcombo_l[3];
1948 bombdoorcset_l[3];
1949 bombdoorcombo_r[3];
1950 bombdoorcset_r[3];
1951 walkthroughcombo[4];
1952 walkthroughcset[4];
1953 */
1954 7072 }
1955
1956 905216 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1957 {
1958 905216 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1959 }
1960
1961 905216 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1962 {
1963
1964 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1965 }
1966
1967 905216 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1968 {
1969 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1970 }
1971
1972
1973 16 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1974 {
1975 char temp_pwd[30];
1976 16 memset(temp_pwd,0,30);
1977
1978
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(pwdkey!=0)
1979 {
1980 16 memcpy(temp_pwd,encrypted_pwd,30);
1981 16 temp_pwd[29]=0;
1982
1983
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 16 times.
496 for(int32_t i=0; i<30; i++)
1984 {
1985 480 temp_pwd[i] -= pwdkey;
1986 480 int32_t t=pwdkey>>15;
1987 480 pwdkey = (pwdkey<<1)+t;
1988 480 }
1989 16 }
1990
1991 16 memcpy(pwd,temp_pwd,30);
1992 16 }
1993
1994
1995 92 bool devpwd()
1996 {
1997 #ifdef _DEBUG
1998 return true;
1999 #endif
2000 92 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio);
2001 }
2002 bool check_questpwd(zquestheader *Header, char *pwd)
2003 {
2004 #if DEVLEVEL > 3
2005 return true;
2006 #endif
2007
2008 if (devpwd()) return true;
2009 if ( (!strcmp(pwd, (char*)clavio)) ) return true;
2010 cvs_MD5Context ctx;
2011 uint8_t md5sum[16];
2012
2013 cvs_MD5Init(&ctx);
2014 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
2015 cvs_MD5Final(md5sum, &ctx);
2016
2017 return (memcmp(Header->pwd_hash,md5sum,16)==0);
2018 }
2019
2020 120 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2021 {
2022 120 zprint2("\n");
2023 120 zprint2("[ZQUEST CREATOR METADATA]\n");
2024
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(qst_num < moduledata.max_quest_files)
2025 zprint2("Loading module quest %d\n", qst_num+1);
2026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(path) zprint2("Loading '%s'\n", path);
2027
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 4 times.
120 if ( tempheader.new_version_id_main > 0 )
2028 {
2029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(tempheader.new_version_id_fourth > 0)
2030 zprint2("Last saved in ZQuest Version %d.%d.%d.%d ",
2031 tempheader.new_version_id_main,tempheader.new_version_id_second,
2032 tempheader.new_version_id_third,tempheader.new_version_id_fourth);
2033 116 else zprint2("Last saved in ZQuest Version: %d.%d.%d ",
2034 116 tempheader.new_version_id_main,tempheader.new_version_id_second,
2035 116 tempheader.new_version_id_third);
2036 116 }
2037 else
2038 {
2039
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 switch ( tempheader.zelda_version )
2040 {
2041 case 0x255:
2042 {
2043 zprint2("Last saved in ZQuest Version: 2.55.0, %s: %d", tempheader.getAlphaStr(), tempheader.getAlphaVer());
2044 break;
2045 }
2046 case 0x254:
2047 {
2048 zprint2("Last saved in ZQuest Version: 2.54.0, Alpha Build ID: %d", tempheader.build);
2049 break;
2050 }
2051 case 0x250:
2052 {
2053 switch(tempheader.build)
2054 {
2055 case 19:
2056 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 1"); break;
2057 case 20:
2058 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 2"); break;
2059 case 21:
2060 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 3"); break;
2061 case 22:
2062 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 4"); break;
2063 case 23:
2064 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 5"); break;
2065 case 24:
2066 zprint2("Last saved in ZQuest Version: 2.50.0, Release"); break;
2067 case 25:
2068 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 1"); break;
2069 case 26:
2070 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 2"); break;
2071 case 27:
2072 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 3"); break;
2073 case 28:
2074 zprint2("Last saved in ZQuest Version: 2.50.1, Release"); break;
2075 case 29:
2076 zprint2("Last saved in ZQuest Version: 2.50.2, Release"); break;
2077 case 30:
2078 zprint2("Last saved in ZQuest Version: 2.50.3, Gamma 1"); break;
2079 case 31:
2080 zprint2("Last saved in ZQuest Version: 2.53.0, Prior to Gamma 3"); break;
2081 case 32:
2082 zprint2("Last saved in ZQuest Version: 2.53.0"); break;
2083 case 33:
2084 zprint2("Last saved in ZQuest Version: 2.53.1"); break;
2085 default:
2086 zprint2("Last saved in ZQuest Version: %x, Build %d", tempheader.zelda_version,tempheader.build); break;
2087
2088 }
2089 break;
2090 }
2091
2092 case 0x211:
2093 {
2094 zprint2("Last saved in ZQuest Version: 2.11, Beta %d", tempheader.build); break;
2095 }
2096 case 0x210:
2097 {
2098 zprint2("Last saved in ZQuest Version: 2.10.x");
2099 if ( tempheader.build ) zprint2("Beta/Build %d\n", tempheader.build);
2100 break;
2101 }
2102 /* These versions cannot be handled here; they will be incorrect at this time. -Z
2103 case 0x193:
2104 {
2105 zprint2("Last saved in ZQuest Version: 1.93, Beta %d\n", tempheader.build); break;
2106 }
2107 case 0x192:
2108 {
2109 zprint2("Last saved in ZQuest Version: 1.92, Beta %d\n", tempheader.build); break;
2110 }
2111 case 0x190:
2112 {
2113 zprint2("Last saved in ZQuest Version: 1.90, Beta/Build %d\n", tempheader.build); break;
2114 }
2115 case 0x184:
2116 {
2117 zprint2("Last saved in ZQuest Version: 1.84, Beta/Build %d\n", tempheader.build); break;
2118 }
2119 case 0x183:
2120 {
2121 zprint2("Last saved in ZQuest Version: 1.83, Beta/Build %d\n", tempheader.build); break;
2122 }
2123 case 0x180:
2124 {
2125 zprint2("Last saved in ZQuest Version: 1.80, Beta/Build %d\n", tempheader.build); break;
2126 }
2127 default:
2128 {
2129 zprint2("Last saved in ZQuest Version: %x, Beta %d\n", tempheader.zelda_version,tempheader.build); break;
2130 }
2131 */
2132 }
2133 }
2134
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
120 if(!tempheader.is_legacy() && tempheader.getAlphaVer())
2135 27 zprint2("%s\n", tempheader.getAlphaVerStr());
2136 93 else zprint2("\n");
2137
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 27 times.
120 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2138
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 27 times.
120 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2139
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 27 times.
120 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2140
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 27 times.
120 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2141
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 116 times.
120 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2142
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 27 times.
120 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2143 120 zprint2("\n");
2144 120 }
2145
2146 128 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
2147 {
2148 int32_t dummy;
2149 zquestheader tempheader;
2150 char dummybuf[80];
2151 byte temp_map_count;
2152 byte temp_midi_flags[MIDIFLAGS_SIZE];
2153 word version;
2154 char temp_pwd[30], temp_pwd2[30];
2155 int16_t temp_pwdkey;
2156 cvs_MD5Context ctx;
2157 128 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2158 128 memset(&tempheader, 0, sizeof(tempheader));
2159 128 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2160
2161
2162
2163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
2164 {
2165 Z_message("Unable to read header string\n");
2166 return qe_invalid;
2167 }
2168
2169 // check header
2170
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2171 {
2172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2173 {
2174 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2175 return qe_invalid;
2176 }
2177 4 }
2178
2179 128 int32_t templatepath_len=0;
2180
2181 128 tempheader.external_zinfo = false;
2182 128 read_zinfo = false;
2183
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2184 {
2185 byte padding;
2186
2187
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f))
2188 {
2189 return qe_invalid;
2190 }
2191
2192
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.zelda_version,f))
2193 {
2194 return qe_invalid;
2195 }
2196
2197 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2198
2199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version > ZELDA_VERSION)
2200 {
2201 return qe_version;
2202 }
2203
2204 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2205
2206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2207 {
2208 return qe_invalid;
2209 }
2210
2211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(bad_version(tempheader.zelda_version))
2212 {
2213 return qe_obsolete;
2214 }
2215
2216
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.internal,f))
2217 {
2218 return qe_invalid;
2219 }
2220
2221
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.quest_number,f))
2222 {
2223 return qe_invalid;
2224 }
2225
2226 4 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2227
2228
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[0],2,f))
2229 {
2230 return qe_invalid;
2231 }
2232
2233
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_map_count,f))
2234 {
2235 return qe_invalid;
2236 }
2237
2238 4 FFCore.quest_format[qMapCount] = temp_map_count;
2239
2240
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.old_str_count,f))
2241 {
2242 return qe_invalid;
2243 }
2244
2245
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2246 {
2247 return qe_invalid;
2248 }
2249
2250
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_midi_flags,4,f))
2251 {
2252 return qe_invalid;
2253 }
2254
2255
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2256 {
2257 return qe_invalid;
2258 }
2259
2260
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,14,f))
2261 {
2262 return qe_invalid;
2263 }
2264
2265
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[2],2,f))
2266 {
2267 return qe_invalid;
2268 }
2269
2270
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&dummybuf,f))
2271 {
2272 return qe_invalid;
2273 }
2274
2275
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.version,9,f))
2276 {
2277 return qe_invalid;
2278 }
2279
2280
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2281 {
2282 return qe_invalid;
2283 }
2284 // These fields are expected to end in null bytes!
2285 4 tempheader.title[sizeof(tempheader.title)-1] = 0;
2286
2287
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2288 {
2289 return qe_invalid;
2290 }
2291 4 tempheader.author[sizeof(tempheader.author)-1] = 0;
2292
2293
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f))
2294 {
2295 return qe_invalid;
2296 }
2297
2298
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&temp_pwdkey,f))
2299 {
2300 return qe_invalid;
2301 }
2302
2303
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_pwd,30,f))
2304 {
2305 return qe_invalid;
2306 }
2307
2308 4 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2309 4 cvs_MD5Init(&ctx);
2310 4 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2311 4 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2312
2313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2314 {
2315 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2316 // Not anymore...
2317 memset(tempheader.minver,0,17);
2318 tempheader.build=0;
2319 tempheader.use_keyfile=0;
2320 memset(tempheader.old_foo, 0, 9);
2321 }
2322 else
2323 {
2324
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.minver,9,f))
2325 {
2326 return qe_invalid;
2327 }
2328
2329
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.build,f))
2330 {
2331 return qe_invalid;
2332 }
2333
2334 4 FFCore.quest_format[vBuild] = tempheader.build;
2335
2336
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.use_keyfile,f))
2337 {
2338 return qe_invalid;
2339 }
2340
2341
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,9,f))
2342 {
2343 return qe_invalid;
2344 }
2345 } // starting at minver
2346
2347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2348 {
2349 memset(&quest_rules[4],0,16); // word rules3..rules10
2350 }
2351 else
2352 {
2353
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2354 {
2355 return qe_invalid; // starting at rules3
2356 }
2357
2358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version <= 0x190)
2359 {
2360 4 set_qr(qr_MEANPLACEDTRAPS,0);
2361 4 }
2362 }
2363
2364
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2365 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2366 {
2367 4 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2368 4 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2369 4 set_qr(qr_BRKBLSHLDS_DEP,1);
2370 4 }
2371
2372
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2373 {
2374 byte *mf=temp_midi_flags;
2375
2376 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2377 {
2378 mf=(byte*)dummybuf;
2379 }
2380
2381 if(!pfread(mf,32,f)) // read new header additions
2382 {
2383 return qe_invalid; // starting at foo2
2384 }
2385
2386 if(!pfread(dummybuf,18,f)) // read new header additions
2387 {
2388 return qe_invalid; // starting at foo2
2389 }
2390 }
2391
2392
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2393 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2394 {
2395 4 memset(tempheader.templatepath,0,2048);
2396 4 }
2397 else
2398 {
2399 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2400 {
2401 return qe_invalid;
2402 }
2403 }
2404
2405
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2406 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2407 {
2408 4 tempheader.use_keyfile=0;
2409 4 }
2410 4 }
2411 else
2412 {
2413 //section id
2414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(!p_mgetl(&dummy,f))
2415 {
2416 return qe_invalid;
2417 }
2418
2419 //section version info
2420
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&version,f))
2421 {
2422 return qe_invalid;
2423 }
2424
2425 124 FFCore.quest_format[vHeader] = version;
2426
2427
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&dummy,f))
2428 {
2429 return qe_invalid;
2430 }
2431
2432 //section size
2433
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&dummy,f))
2434 {
2435 return qe_invalid;
2436 }
2437
2438 //finally... section data
2439
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&tempheader.zelda_version,f))
2440 {
2441 return qe_invalid;
2442 }
2443
2444 124 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2445
2446 //do some quick checking...
2447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(tempheader.zelda_version > ZELDA_VERSION)
2448 {
2449 return qe_version;
2450 }
2451
2452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2453 {
2454 return qe_invalid;
2455 }
2456
2457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(bad_version(tempheader.zelda_version))
2458 {
2459 return qe_obsolete;
2460 }
2461
2462
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_getc(&tempheader.build,f))
2463 {
2464 return qe_invalid;
2465 }
2466
2467 124 FFCore.quest_format[vBuild] = tempheader.build;
2468
2469
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 112 times.
124 if(version<3)
2470 {
2471
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!pfread(temp_pwd,30,f))
2472 {
2473 return qe_invalid;
2474 }
2475
2476
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&temp_pwdkey,f))
2477 {
2478 return qe_invalid;
2479 }
2480
2481 12 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2482 12 cvs_MD5Init(&ctx);
2483 12 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2484 12 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2485 12 }
2486 else
2487 {
2488
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2489 {
2490 return qe_invalid;
2491 }
2492 }
2493
2494
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&tempheader.internal,f))
2495 {
2496 return qe_invalid;
2497 }
2498
2499
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_getc(&tempheader.quest_number,f))
2500 {
2501 return qe_invalid;
2502 }
2503
2504 124 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2505
2506 124 size_t versz = version < 8 ? 9 : 16;
2507
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!pfread(tempheader.version,versz,f))
2508 {
2509 return qe_invalid;
2510 }
2511
2512 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2513 //needs to be copied as char[9] or stored as a s.str
2514
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!pfread(tempheader.minver,versz,f))
2515 {
2516 return qe_invalid;
2517 }
2518
2519 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2520
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2521 {
2522 return qe_invalid;
2523 }
2524 124 tempheader.title[sizeof(tempheader.title)-1] = 0;
2525
2526
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2527 {
2528 return qe_invalid;
2529 }
2530 124 tempheader.author[sizeof(tempheader.author)-1] = 0;
2531
2532
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_getc(&tempheader.use_keyfile,f))
2533 {
2534 return qe_invalid;
2535 }
2536
2537 /*
2538 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2539 {
2540 return qe_invalid;
2541 }
2542 */
2543
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2544 {
2545 return qe_invalid;
2546 }
2547
2548
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!pfread(&dummybuf,4,f))
2549 {
2550 return qe_invalid;
2551 }
2552
2553
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2554 {
2555 return qe_invalid;
2556 }
2557
2558
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!pfread(dummybuf,14,f))
2559 {
2560 return qe_invalid;
2561 }
2562
2563 124 templatepath_len=sizeof(tempheader.templatepath);
2564
2565
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 12 times.
124 if(version==1)
2566 {
2567 12 templatepath_len=280;
2568 12 }
2569
2570
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!pfread(tempheader.templatepath,templatepath_len,f))
2571 {
2572 return qe_invalid;
2573 }
2574
2575
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_getc(&temp_map_count,f))
2576 {
2577 return qe_invalid;
2578 }
2579
2580
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 89 times.
124 if(version>=4)
2581 {
2582
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tempheader.new_version_id_main,f))
2583 {
2584 return qe_invalid;
2585 }
2586
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tempheader.new_version_id_second,f))
2587 {
2588 return qe_invalid;
2589 }
2590
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tempheader.new_version_id_third,f))
2591 {
2592 return qe_invalid;
2593 }
2594
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2595 {
2596 return qe_invalid;
2597 }
2598
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2599 {
2600 return qe_invalid;
2601 }
2602
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tempheader.new_version_id_beta,f))
2603 {
2604 return qe_invalid;
2605 }
2606
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2607 {
2608 return qe_invalid;
2609 }
2610
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tempheader.new_version_id_release,f))
2611 {
2612 return qe_invalid;
2613 }
2614
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2615 {
2616 return qe_invalid;
2617 }
2618
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&tempheader.new_version_id_date_month,f))
2619 {
2620 return qe_invalid;
2621 }
2622
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&tempheader.new_version_id_date_day,f))
2623 {
2624 return qe_invalid;
2625 }
2626
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2627 {
2628 return qe_invalid;
2629 }
2630
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2631 {
2632 return qe_invalid;
2633 }
2634
2635
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!pfread(tempheader.new_version_devsig,256,f))
2636 {
2637 return qe_invalid;
2638 }
2639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2640 strcpy(tempheader.new_version_devsig, "EmilyV99");
2641
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!pfread(tempheader.new_version_compilername,256,f))
2642 {
2643 return qe_invalid;
2644 }
2645
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!pfread(tempheader.new_version_compilerversion,256,f))
2646 {
2647 return qe_invalid;
2648 }
2649
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!pfread(tempheader.product_name,1024,f))
2650 {
2651 return qe_invalid;
2652 }
2653
2654
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&tempheader.compilerid,f))
2655 {
2656 return qe_invalid;
2657 }
2658
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2659 {
2660 return qe_invalid;
2661 }
2662
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2663 {
2664 return qe_invalid;
2665 }
2666
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2667 {
2668 return qe_invalid;
2669 }
2670
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2671 {
2672 return qe_invalid;
2673 }
2674
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetw(&tempheader.developerid,f))
2675 {
2676 return qe_invalid;
2677 }
2678
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!pfread(tempheader.made_in_module_name,1024,f))
2679 {
2680 return qe_invalid;
2681 }
2682
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!pfread(tempheader.build_datestamp,256,f))
2683 {
2684 return qe_invalid;
2685 }
2686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(!pfread(tempheader.build_timestamp,256,f))
2687 {
2688 return qe_invalid;
2689 }
2690 35 }
2691 else // <4
2692 {
2693 89 tempheader.new_version_id_main = 0;
2694 89 tempheader.new_version_id_second = 0;
2695 89 tempheader.new_version_id_third = 0;
2696 89 tempheader.new_version_id_fourth = 0;
2697 89 tempheader.new_version_id_alpha = 0;
2698 89 tempheader.new_version_id_beta = 0;
2699 89 tempheader.new_version_id_gamma = 0;
2700 89 tempheader.new_version_id_release = 0;
2701 89 tempheader.new_version_id_date_year = 0;
2702 89 tempheader.new_version_id_date_month = 0;
2703 89 tempheader.new_version_id_date_day = 0;
2704 89 tempheader.new_version_id_date_hour = 0;
2705 89 tempheader.new_version_id_date_minute = 0;
2706
2707 89 memset(tempheader.new_version_devsig, 0, 256);
2708 89 memset(tempheader.new_version_compilername, 0, 256);
2709 89 memset(tempheader.new_version_compilerversion, 0, 256);
2710 89 memset(tempheader.product_name, 0, 1024);
2711 89 strcpy(tempheader.product_name, "ZQuest Creator Suite");
2712
2713 89 tempheader.compilerid = 0;
2714 89 tempheader.compilerversionnumber_first = 0;
2715 89 tempheader.compilerversionnumber_second = 0;
2716 89 tempheader.compilerversionnumber_third = 0;
2717 89 tempheader.compilerversionnumber_fourth = 0;
2718 89 tempheader.developerid = 0;
2719
2720 89 memset(tempheader.made_in_module_name, 0, 1024);
2721 89 memset(tempheader.build_datestamp, 0, 256);
2722 89 memset(tempheader.build_timestamp, 0, 256);
2723 }
2724
2725
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 89 times.
124 if ( version >= 5 )
2726 {
2727
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!pfread(tempheader.build_timezone,6,f))
2728 {
2729 return qe_invalid;
2730 }
2731 35 }
2732 else // < 5
2733 {
2734 89 memset(tempheader.build_timezone, 0, 6);
2735 }
2736
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 35 times.
124 if ( version >= 6 )
2737 {
2738 byte b;
2739
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&b,f))
2740 {
2741 return qe_invalid;
2742 }
2743 35 tempheader.external_zinfo = b?true:false;
2744 35 read_zinfo = true;
2745 35 }
2746
2747
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 89 times.
124 if(version >= 7)
2748 {
2749
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2750 {
2751 return qe_invalid;
2752 }
2753 35 }
2754 else
2755 {
2756 89 tempheader.new_version_is_nightly = false;
2757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(tempheader.zelda_version < 0x255)
2758 {
2759
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
89 switch(tempheader.zelda_version)
2760 {
2761 case 0x254:
2762 tempheader.new_version_id_main = 2;
2763 tempheader.new_version_id_second = 54;
2764 break;
2765 case 0x250:
2766
6/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 24 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 15 times.
✓ Branch 14 taken 10 times.
✓ Branch 15 taken 1 times.
77 switch(tempheader.build)
2767 {
2768 case 19:
2769 tempheader.new_version_id_main = 2;
2770 tempheader.new_version_id_second = 50;
2771 tempheader.new_version_id_gamma = 1;
2772 break;
2773 case 20:
2774 tempheader.new_version_id_main = 2;
2775 tempheader.new_version_id_second = 50;
2776 tempheader.new_version_id_gamma = 2;
2777 break;
2778 case 21:
2779 tempheader.new_version_id_main = 2;
2780 tempheader.new_version_id_second = 50;
2781 tempheader.new_version_id_gamma = 3;
2782 break;
2783 case 22:
2784 tempheader.new_version_id_main = 2;
2785 tempheader.new_version_id_second = 50;
2786 tempheader.new_version_id_gamma = 4;
2787 break;
2788 case 23:
2789 tempheader.new_version_id_main = 2;
2790 tempheader.new_version_id_second = 50;
2791 tempheader.new_version_id_gamma = 5;
2792 break;
2793 case 24:
2794 22 tempheader.new_version_id_main = 2;
2795 22 tempheader.new_version_id_second = 50;
2796 22 tempheader.new_version_id_release = -1;
2797 22 break;
2798 case 25:
2799 tempheader.new_version_id_main = 2;
2800 tempheader.new_version_id_second = 50;
2801 tempheader.new_version_id_third = 1;
2802 tempheader.new_version_id_gamma = 1;
2803 break;
2804 case 26:
2805 tempheader.new_version_id_main = 2;
2806 tempheader.new_version_id_second = 50;
2807 tempheader.new_version_id_third = 1;
2808 tempheader.new_version_id_gamma = 2;
2809 break;
2810 case 27:
2811 tempheader.new_version_id_main = 2;
2812 tempheader.new_version_id_second = 50;
2813 tempheader.new_version_id_third = 1;
2814 tempheader.new_version_id_gamma = 3;
2815 break;
2816 case 28:
2817 5 tempheader.new_version_id_main = 2;
2818 5 tempheader.new_version_id_second = 50;
2819 5 tempheader.new_version_id_third = 1;
2820 5 tempheader.new_version_id_release = -1;
2821 5 break;
2822 case 29:
2823 24 tempheader.new_version_id_main = 2;
2824 24 tempheader.new_version_id_second = 50;
2825 24 tempheader.new_version_id_third = 2;
2826 24 tempheader.new_version_id_release = -1;
2827 24 break;
2828 case 30:
2829 tempheader.new_version_id_main = 2;
2830 tempheader.new_version_id_second = 50;
2831 tempheader.new_version_id_third = 3;
2832 tempheader.new_version_id_gamma = 1;
2833 break;
2834 case 31:
2835 15 tempheader.new_version_id_main = 2;
2836 15 tempheader.new_version_id_second = 53;
2837 15 tempheader.new_version_id_gamma = -1;
2838 15 break;
2839 case 32:
2840 10 tempheader.new_version_id_main = 2;
2841 10 tempheader.new_version_id_second = 53;
2842 10 tempheader.new_version_id_release = -1;
2843 10 break;
2844 case 33:
2845 1 tempheader.new_version_id_main = 2;
2846 1 tempheader.new_version_id_second = 53;
2847 1 tempheader.new_version_id_third = 1;
2848 1 break;
2849 }
2850 77 break;
2851
2852 case 0x211:
2853 tempheader.new_version_id_main = 2;
2854 tempheader.new_version_id_second = 11;
2855 tempheader.new_version_id_beta = tempheader.build;
2856 break;
2857 case 0x210:
2858 12 tempheader.new_version_id_main = 2;
2859 12 tempheader.new_version_id_second = 10;
2860 12 tempheader.new_version_id_beta = tempheader.build;
2861 12 break;
2862 }
2863 89 }
2864 }
2865
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
124 if(printmetadata || __isZQuest)
2866 {
2867 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2868 }
2869 }
2870
2871 //{ Version Warning
2872 128 int32_t vercmp = tempheader.compareVer();
2873 128 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), ALPHA_STATE);
2874 128 int32_t avercmp = compare(tempheader.getAlphaVer(), ALPHA_VER);
2875
4/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
163 if(vercmp > 0 || (!vercmp &&
2876
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 (astatecmp > 0 || (!astatecmp &&
2877 35 avercmp > 0))))
2878 {
2879 bool r = true;
2880 if(loadquest_report)
2881 {
2882 enter_sys_pal();
2883 AlertDialog("Quest saved in newer version",
2884 "This quest was last saved in a newer version of ZQuest."
2885 " Attempting to load this quest may not work correctly; to"
2886 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2887 "\n\nWould you like to continue loading anyway? (Not recommended)",
2888 [&](bool ret,bool)
2889 {
2890 r = ret;
2891 }).show();
2892 exit_sys_pal();
2893 }
2894 if(!r)
2895 return qe_silenterr;
2896 }
2897
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 else if(tempheader.compareDate() > 0)
2898 {
2899 bool r = true;
2900 if(loadquest_report)
2901 {
2902 enter_sys_pal();
2903 AlertDialog("Quest saved in newer build",
2904 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
2905 " issues loading in this build."
2906 "\n{}"
2907 "\n\nWould you like to continue loading anyway?",
2908 tempheader.getVerCmpStr()),
2909 [&](bool ret,bool)
2910 {
2911 r = ret;
2912 }).show();
2913 exit_sys_pal();
2914 }
2915 if(!r)
2916 return qe_silenterr;
2917 }
2918 //}
2919
2920 128 read_ext_zinfo = tempheader.external_zinfo;
2921
2922 128 memcpy(Header, &tempheader, sizeof(tempheader));
2923 128 map_count=temp_map_count;
2924 128 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2925
2926 128 return 0;
2927 128 }
2928
2929 128 int32_t readrules(PACKFILE *f, zquestheader *Header)
2930 {
2931
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_rules);
2932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (should_skip)
2933 return 0;
2934
2935 int32_t dummy;
2936 zquestheader tempheader;
2937 128 word s_version=0;
2938 128 dword compatrule_version=0;
2939
2940 128 memcpy(&tempheader, Header, sizeof(tempheader));
2941
2942
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(tempheader.zelda_version >= 0x193)
2943 {
2944 //section version info
2945
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&s_version,f))
2946 {
2947 return qe_invalid;
2948 }
2949
2950 124 FFCore.quest_format[vRules] = s_version;
2951
2952
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&dummy,f))
2953 {
2954 return qe_invalid;
2955 }
2956
2957
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 35 times.
124 if(s_version > 16)
2958 {
2959
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&compatrule_version,f))
2960 {
2961 return qe_invalid;
2962 }
2963 35 }
2964 124 FFCore.quest_format[vCompatRule] = compatrule_version;
2965
2966 //section size
2967
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&dummy,f))
2968 {
2969 return qe_invalid;
2970 }
2971
2972
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 35 times.
124 if ( s_version < 15 )
2973 {
2974 //finally... section data
2975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
2976 {
2977 return qe_invalid;
2978 }
2979 89 }
2980 else
2981 {
2982
2983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
2984 {
2985 return qe_invalid;
2986 }
2987
2988 }
2989 124 }
2990
2991 //al_trace("Rules version %d\n", s_version);
2992 //{ bunch of compat stuff
2993 128 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2994
2995
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version<2)
2996 {
2997 16 set_qr(14,0);
2998 16 set_qr(27,0);
2999 16 set_qr(28,0);
3000 16 set_qr(29,0);
3001 16 set_qr(30,0);
3002 16 set_qr(32,0);
3003 16 set_qr(36,0);
3004 16 set_qr(49,0);
3005 16 set_qr(50,0);
3006 16 set_qr(51,0);
3007 16 set_qr(68,0);
3008 16 set_qr(75,0);
3009 16 set_qr(76,0);
3010 16 set_qr(98,0);
3011 16 set_qr(110,0);
3012 16 set_qr(113,0);
3013 16 set_qr(116,0);
3014 16 set_qr(102,0);
3015 16 set_qr(132,0);
3016 16 }
3017
3018 //Now, do any updates...
3019
3/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
3020 {
3021 16 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
3022 16 set_qr(qr_REPLACEOPENDOORS, 1);
3023 16 set_qr(qr_OLDLENSORDER, 1);
3024 16 set_qr(qr_NOFAIRYGUYFIRES, 1);
3025 16 set_qr(qr_TRIGGERSREPEAT, 1);
3026 16 }
3027
3028
3/6
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3029 {
3030 4 set_qr(qr_WALLFLIERS,1);
3031 4 }
3032
3033
3/6
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
3034 {
3035 4 set_qr(qr_NOBOMBPALFLASH,1);
3036 4 }
3037
3038
5/6
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
128 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3039 {
3040 6 set_qr(qr_NOSCROLLCONTINUE,1);
3041 6 }
3042
3043
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 16 times.
130 if(tempheader.zelda_version <= 0x210)
3044 {
3045 16 set_qr(qr_ARROWCLIP,1);
3046 16 }
3047
3048
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 12 times.
126 if(tempheader.zelda_version == 0x210)
3049 {
3050 12 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
3051 12 set_qr(qr_CMBCYCLELAYERS, 0);
3052 12 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
3053 12 }
3054
3055
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 16 times.
126 if(tempheader.zelda_version <= 0x210)
3056 {
3057 16 set_qr(qr_OLDSTYLEWARP,1);
3058 16 set_qr(qr_210_WARPRETURN,1);
3059 16 }
3060
3061 //might not be correct
3062
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 4 times.
126 if(tempheader.zelda_version < 0x210)
3063 {
3064 4 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
3065 4 set_qr(qr_OLDTRIBBLES_DEP,1);
3066 4 set_qr(qr_OLDHOOKSHOTGRAB,1);
3067 4 }
3068
3069
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 16 times.
126 if(tempheader.zelda_version < 0x211)
3070 {
3071 16 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
3072 16 }
3073
3074
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 122 times.
126 if((tempheader.zelda_version == 0x192 && tempheader.build <= 163) || tempheader.zelda_version < 0x192)
3075 {
3076 4 set_qr(qr_192b163_WARP,1);
3077 4 }
3078
3079
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 12 times.
126 if(tempheader.zelda_version == 0x210)
3080 {
3081 12 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3082 12 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3083 12 set_qr(qr_DMGCOMBOPRI, 0);
3084 12 }
3085
3086
5/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
126 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3087 {
3088 16 set_qr(qr_OLDPICKUP,1);
3089 16 }
3090
3091
5/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
130 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3092 {
3093 16 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
3094 16 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3095 16 }
3096
3097
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 16 times.
130 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3098 {
3099 16 set_qr(qr_HOOKSHOTDOWNBUG, 1);
3100 16 }
3101
3102
4/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 49 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 22 times.
126 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3103 {
3104 22 set_qr(qr_PEAHATCLOCKVULN, 1);
3105 22 }
3106
3107
6/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 75 times.
126 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3108 {
3109 16 set_qr(qr_OLD_DOORREPAIR, 1);
3110 16 }
3111
3112
6/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 79 times.
126 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3113 {
3114 16 set_qr(qr_OLD_SECRETMONEY, 1);
3115 16 }
3116
3117
6/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 57 times.
130 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3118 {
3119 38 set_qr(qr_OLD_POTION_OR_HC, 1);
3120 38 }
3121
3122
6/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 57 times.
130 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3123 {
3124 38 set_qr(qr_OFFSCREENWEAPONS, 1);
3125 38 }
3126
3127 //Bombchu fix.
3128
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 77 times.
130 if(tempheader.zelda_version == 0x250)
3129 {
3130
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 22 times.
77 if ( tempheader.build == 24 ) //2.50.0
3131 {
3132 22 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3133 22 }
3134
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 5 times.
77 if ( tempheader.build == 28 ) //2.50.1
3135 {
3136 5 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3137 5 }
3138
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 24 times.
77 if ( tempheader.build == 29 ) //2.50.2
3139 {
3140 24 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3141 24 }
3142
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if ( tempheader.build == 30 ) //2.50.3RC1
3143 {
3144 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3145 }
3146 77 }
3147
3148
6/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 52 times.
130 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3149 {
3150 // qr_OFFSETEWPNCOLLISIONFIX
3151 // All 'official' quests need this disabled.
3152 // All 2.10 and lower quests need this enabled to preseve compatability.
3153 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3154
3155 //~Gleeok
3156 43 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3157
3158 // Broke in build 695
3159
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
43 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3160 27 set_qr(qr_BROKENSTATUES, 1);
3161 43 }
3162
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if (tempheader.zelda_version <= 0x190)
3163 {
3164 4 set_qr(qr_COPIED_SWIM_SPRITES, 1);
3165 4 }
3166
9/10
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 53 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 35 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 35 times.
130 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3167 {
3168 94 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
3169 94 }
3170
3171
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3172 {
3173 16 set_qr(qr_OLD_210_WATER, 1);
3174 16 }
3175
3176
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3177 {
3178 93 set_qr(qr_STEP_IS_FLOAT,0);
3179 93 }
3180
3181
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if ( tempheader.zelda_version < 0x250 )
3182 {
3183 16 set_qr(qr_8WAY_SHOT_SFX, 1);
3184 16 }
3185
3186
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version < 3)
3187 {
3188 16 set_qr(qr_HOLDNOSTOPMUSIC, 1);
3189 16 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
3190 16 }
3191
3192
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version<4)
3193 {
3194 16 set_qr(10,0);
3195 16 }
3196
3197
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version<5)
3198 {
3199 16 set_qr(27,0);
3200 16 }
3201
3202
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version<6)
3203 {
3204 16 set_qr(46,0);
3205 16 }
3206
3207
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version<7) // January 2008
3208 {
3209 16 set_qr(qr_HEARTSREQUIREDFIX,0);
3210 16 set_qr(qr_PUSHBLOCKCSETFIX,1);
3211 16 }
3212
3213
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 112 times.
128 if(s_version<8)
3214 {
3215 16 set_qr(12, 0);
3216 16 }
3217 else
3218 {
3219 112 set_bit(deprecated_rules, 12, 0);
3220 }
3221
3222
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version<9) // October 2008
3223 {
3224 16 set_qr(qr_NOROPE2FLASH_DEP,0);
3225 16 set_qr(qr_NOBUBBLEFLASH_DEP,0);
3226 16 set_qr(qr_GHINI2BLINK_DEP,0);
3227 16 set_qr(qr_PHANTOMGHINI2_DEP,0);
3228 16 }
3229
3230
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version<10) // December 2008
3231 {
3232 16 set_qr(qr_NOCLOCKS_DEP,0);
3233 16 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
3234 16 }
3235
3236
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version<11) // April 2009
3237 {
3238 16 set_qr(qr_SLOWENEMYANIM_DEP,0);
3239 16 }
3240
3241 // This served no purpose.
3242 // if(s_version<12) // December 2009
3243 // {
3244 // set_qr(qr_BRKBLSHLDS_DEP,0);
3245 // set_qr(qr_OLDTRIBBLES_DEP,0);
3246 // }
3247
3248 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3249
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version < 13)
3250 {
3251 16 set_qr(qr_SHOPCHEAT, 1);
3252 16 }
3253
3254 // Not entirely sure this is the best place for this...
3255 //2.50.2 bitmap offset fix
3256 128 memset(extra_rules, 0, EXTRARULES_SIZE);
3257
6/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 50 times.
128 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3258 {
3259 43 set_er(er_BITMAPOFFSET, 1);
3260 43 set_qr(qr_BITMAPOFFSETFIX, 1);
3261 43 }
3262 //required because quest templates also used this bit, although
3263 //it never did anything, before. -Z
3264
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 77 times.
128 if ( tempheader.zelda_version == 0x250 )
3265 {
3266
5/6
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 38 times.
77 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3267 {
3268 39 set_er(er_BITMAPOFFSET, 0);
3269 39 set_qr(qr_BITMAPOFFSETFIX, 0);
3270 39 }
3271 77 }
3272
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if ( tempheader.zelda_version == 0x254 )
3273 {
3274 set_er(er_BITMAPOFFSET, 0);
3275 set_qr(qr_BITMAPOFFSETFIX, 0);
3276 }
3277
3/4
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
128 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3278 {
3279 set_er(er_BITMAPOFFSET, 0);
3280 set_qr(qr_BITMAPOFFSETFIX, 0);
3281 }
3282 //optimise fast drawing for older versions.
3283
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3284 {
3285 93 set_qr(qr_OLDSPRITEDRAWS, 1);
3286 93 }
3287 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3288 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3289 //older quests can set the rule by hand. We need a new qst.dat again.
3290
4/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3291 {
3292 set_qr(qr_OLDEWPNPARENT, 1);
3293 }
3294
4/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3295 {
3296 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3297 }
3298
4/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3299 {
3300 set_qr(qr_OLDQUESTMISC, 1);
3301 }
3302
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if ( tempheader.zelda_version < 0x254 )
3303 {
3304 93 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3305 93 set_qr(qr_OLDEWPNPARENT, 0);
3306 93 set_qr(qr_OLDQUESTMISC, 0);
3307 93 }
3308
3309 //item scripts continue to run
3310
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3311 {
3312 93 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3313 93 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3314 93 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3315 93 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3316 93 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3317 93 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3318 93 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3319 93 }
3320
3321
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3322 {
3323 93 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3324 93 }
3325
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3326 {
3327 93 set_qr(qr_TRACESCRIPTIDS, 0);
3328 93 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3329 93 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3330 93 set_qr(qr_PARSER_250DIVISION,1);
3331 93 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3332 93 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3333 93 set_qr(qr_PARSER_FORCE_INLINE,0);
3334 93 set_qr(qr_PARSER_BINARY_32BIT,0);
3335
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 2 times.
93 if ( get_qr(qr_SELECTAWPN) )
3336 {
3337 2 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3338 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3339 //Now they **do**, unless you disable that behaviour.
3340 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3341 //now enable the disable L/R item swap on load.
3342 2 }
3343
3344 93 }
3345
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3346 {
3347 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3348 93 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3349 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3350 //animations ending earlier than they should.
3351 93 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3352 //Enemies would ignore solidity on the top half of combos
3353 93 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3354 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3355 93 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3356 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3357 93 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3358 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3359 93 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3360 93 }
3361
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if ( tempheader.zelda_version < 0x255 )
3362 {
3363 93 set_qr(qr_NOFFCWAITDRAW, 1);
3364 93 set_qr(qr_NOITEMWAITDRAW, 1);
3365 93 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3366 93 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3367 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3368 93 }
3369
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3370 {
3371 93 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3372 93 }
3373
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3374 {
3375 93 set_qr(qr_OLD_PRINTF_ARGS, 1);
3376 93 }
3377
3378
3379
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3380 {
3381 93 set_qr(qr_BROKEN_RING_POWER, 1);
3382 93 }
3383
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3384 {
3385 93 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3386 93 }
3387
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3388 {
3389 93 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3390 93 }
3391
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3392 {
3393 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3394
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(get_qr(qr_SET_XBUTTON_ITEMS))
3395 set_qr(qr_SET_YBUTTON_ITEMS,1);
3396 93 }
3397
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3398 {
3399 93 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3400 93 }
3401
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3402 {
3403 93 set_qr(qr_OLD_CHEST_COLLISION,1);
3404 93 }
3405
3406
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if ( tempheader.zelda_version < 0x254 )
3407 {
3408 93 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3409 93 }
3410 //Sideview spikes in 2.50.0
3411
6/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 55 times.
128 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3412 {
3413 38 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3414 38 }
3415 //more 2.50 fixes -Z
3416
6/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 26 times.
128 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3417 {
3418 67 set_qr(qr_MELEEMAGICCOST, 0);
3419 67 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3420 67 set_qr(qr_OLDMIRRORCOMBOS, 1);
3421 67 set_qr(qr_BROKENBOOKCOST, 1);
3422 67 set_qr(qr_BROKENCHARINTDRAWING, 1);
3423
3424 67 }
3425
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
128 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3426 {
3427 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3428 set_qr(qr_MELEEMAGICCOST, 1);
3429 }
3430
3431
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if(tempheader.zelda_version < 0x193)
3432 {
3433 4 set_qr(qr_SHORTDGNWALK, 1);
3434 4 }
3435
3436
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(tempheader.zelda_version < 0x255)
3437 {
3438 93 set_qr(qr_OLDINFMAGIC, 1);
3439 93 }
3440
3441
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3442 {
3443 16 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3444 16 }
3445
3446
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3447 {
3448 93 set_qr(qr_OLD_F6,1);
3449 93 }
3450
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3451 {
3452 93 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3453 93 }
3454
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3455 {
3456 93 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3457 93 }
3458
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3459 {
3460 93 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3461 93 }
3462 //}
3463
3464
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3465 93 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3466
3467
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 2) //Old CSet2 Handling
3468 93 set_qr(qr_OLDCS2,1);
3469
3470
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3471 93 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3472
3473
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3474 93 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3475
3476
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 77 times.
128 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3477 77 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3478
3479
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3480 93 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3481
3482
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3483 93 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3484
3485
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3486 93 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3487
3488
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 9)
3489 {
3490 //Hardcoded BS Patras
3491 93 set_qr(qr_HARDCODED_BS_PATRA,1);
3492 //Hardcoded Patra Inner Eye offsets
3493 93 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3494 //Broken 'Big enemy' animation style
3495 93 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3496 //Broken Attribute 31/32
3497 93 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3498 93 }
3499
3500
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 10) //Shared candle use limits
3501 93 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3502
3503
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 11) //No cross-screen return points
3504 93 set_qr(qr_OLD_RESPAWN_POINTS,1);
3505
3506
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 12)
3507 {
3508 //Old fire trail duration
3509 93 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3510 //Old Intro String in Ganon Room Behavior
3511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3512 93 else set_qr(qr_GANONINTRO,1);
3513 93 }
3514
3515
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
128 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3516 set_qr(qr_ANONE_NOANIM,1);
3517
3518
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 14) //Old Bridge Combo Behavior
3519 93 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3520
3521
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 15) //Broken Z3 Animation
3522 93 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3523
3524
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3525 93 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3526
3527
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 17)
3528 {
3529 //Old Quake/DrawYOffset behavior
3530 //set_qr(qr_OLD_DRAWOFFSET,1);
3531 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3532 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3533 93 }
3534
3535
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 18)
3536 {
3537 //Broken DrawScreen Derivative Functions
3538 93 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3539 //Scrolling Cancels Charge
3540 93 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3541 93 }
3542
3543
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3544 93 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3545
3546
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 20)
3547 93 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3548
3549
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 21)
3550 {
3551 93 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3552 93 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3553 93 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3554 93 set_qr(qr_OLD_BUG_NET,1);
3555 93 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3556 93 }
3557
3558
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 22)
3559 93 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3560
3561
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 23)
3562 93 set_qr(qr_OLD_HALF_MAGIC,1);
3563
3564
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 24)
3565 {
3566 93 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3567 93 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3568 93 }
3569
3570
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 25)
3571 {
3572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3573 93 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3574 93 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3575 93 }
3576
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 26)
3577 {
3578 93 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3579 93 set_qr(qr_POLVIRE_NO_SHADOW,1);
3580 93 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3581 93 }
3582
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3583 {
3584
2/2
✓ Branch 0 taken 27993 times.
✓ Branch 1 taken 93 times.
28086 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3585 27993 set_qr(q,0);
3586
2/2
✓ Branch 0 taken 10416 times.
✓ Branch 1 taken 93 times.
10509 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < QUESTRULES_NEW_SIZE*8; ++q)
3587 10416 set_qr(q,0);
3588 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3589 93 }
3590
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 95 times.
128 if(compatrule_version < 28)
3591 95 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3592
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 95 times.
128 if(compatrule_version < 29)
3593 95 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3594
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 95 times.
128 if(compatrule_version < 30)
3595 {
3596 95 set_qr(qr_DECO_2_YOFFSET,1);
3597 95 set_qr(qr_SCREENSTATE_80s_BUG,1);
3598 95 }
3599
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 95 times.
128 if(compatrule_version < 31)
3600 {
3601 95 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3602 95 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3603 95 }
3604
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 95 times.
128 if(compatrule_version < 32)
3605 95 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3606
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 95 times.
128 if(compatrule_version < 33)
3607 95 set_qr(qr_NO_LIFT_SPRITE,1);
3608
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 95 times.
128 if(compatrule_version < 34)
3609 {
3610 95 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3611 95 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3612 95 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3613 95 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3614 95 }
3615
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 96 times.
128 if(compatrule_version < 35)
3616 {
3617 96 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3618 96 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3619 96 }
3620
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 96 times.
128 if(compatrule_version < 36)
3621 96 set_qr(qr_OLD_SHALLOW_SFX,1);
3622
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 98 times.
128 if(compatrule_version < 37)
3623 98 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3624
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 98 times.
128 if(compatrule_version < 38)
3625 98 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3626
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 98 times.
128 if(compatrule_version < 39)
3627 98 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3628
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 98 times.
128 if(compatrule_version < 40)
3629 98 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3630
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 99 times.
128 if(compatrule_version < 41)
3631 99 set_qr(qr_BROKENHITBY,1);
3632
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 99 times.
128 if(compatrule_version < 42)
3633 99 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3634
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 99 times.
128 if(compatrule_version < 43)
3635 99 set_qr(qr_OLD_BOMB_HITBOXES,1);
3636
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 99 times.
128 if(compatrule_version < 44)
3637 99 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3638
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 99 times.
128 if(compatrule_version < 45)
3639 99 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3640
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 99 times.
128 if(compatrule_version < 46)
3641 99 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3642
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 102 times.
128 if(compatrule_version < 47)
3643 {
3644 102 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3645 102 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3646 102 }
3647
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 102 times.
128 if(compatrule_version < 48)
3648 102 set_qr(qr_OLD_GUY_HANDLING,1);
3649
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 102 times.
128 if(compatrule_version < 49)
3650 102 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3651
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 102 times.
128 if(compatrule_version < 50)
3652 102 set_qr(qr_OLD_LENS_LAYEREFFECT,1);
3653
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 102 times.
128 if(compatrule_version < 51)
3654 102 set_qr(qr_PUSHBLOCK_SPRITE_LAYER,1);
3655
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 102 times.
128 if (compatrule_version < 52)
3656 102 set_qr(qr_OLD_SCRIPT_VOLUME, 1);
3657
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 102 times.
128 if(compatrule_version < 53)
3658 {
3659 102 set_qr(qr_OLD_SUBSCR,1);
3660 102 set_qr(qr_ITM_0_INVIS_ON_BTNS,1);
3661 102 set_qr(qr_OLD_GAUGE_TILE_LAYOUT,1);
3662 102 }
3663
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 120 times.
128 if(compatrule_version < 54)
3664 120 set_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE,1);
3665
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 120 times.
128 if(compatrule_version < 55)
3666 120 set_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ,1);
3667
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 120 times.
128 if(compatrule_version < 56)
3668 120 set_qr(qr_BROKEN_LIGHTBEAM_HITBOX,1);
3669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(compatrule_version < 57)
3670 128 set_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS,1);
3671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(compatrule_version < 58)
3672 128 set_qr(qr_OLD_DMAP_INTRO_STRINGS,1);
3673
3674 128 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3675
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if (s_version < 16)
3676 93 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3677
3678 128 memcpy(Header, &tempheader, sizeof(tempheader));
3679
3680 128 return 0;
3681 128 }
3682
3683 1076245 void init_msgstr(MsgStr *str)
3684 {
3685 1076245 str->s = "";
3686 1076245 str->s.shrink_to_fit();
3687 1076245 str->nextstring=0;
3688 1076245 str->tile=0;
3689 1076245 str->cset=0;
3690 1076245 str->trans=false;
3691 1076245 str->font=font_zfont;
3692 1076245 str->y=32;
3693 1076245 str->sfx=18;
3694 1076245 str->listpos=0;
3695 1076245 str->x=24;
3696 1076245 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3697 1076245 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3698 1076245 str->hspace=0;
3699 1076245 str->vspace=0;
3700 1076245 str->stringflags=0;
3701 1076245 str->margins[up] = 8;
3702 1076245 str->margins[down] = 0;
3703 1076245 str->margins[left] = 8;
3704 1076245 str->margins[right] = 0;
3705 1076245 str->portrait_tile = 0;
3706 1076245 str->portrait_cset = 0;
3707 1076245 str->portrait_x = 0;
3708 1076245 str->portrait_y = 0;
3709 1076245 str->portrait_tw = 1;
3710 1076245 str->portrait_th = 1;
3711 1076245 str->shadow_type = 0;
3712 1076245 str->shadow_color = 0;
3713 1076245 str->drawlayer = 6;
3714 1076245 }
3715
3716 128 void init_msgstrings(int32_t start, int32_t end)
3717 {
3718
2/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
128 if(end <= start || end-start > msg_strings_size)
3719 return;
3720
3721
2/2
✓ Branch 0 taken 1048576 times.
✓ Branch 1 taken 128 times.
1048704 for(int32_t i=start; i<end; i++)
3722 {
3723 1048576 init_msgstr(&MsgStrings[i]);
3724 1048576 MsgStrings[i].listpos=i;
3725 1048576 }
3726
3727
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(start==0)
3728 {
3729 128 MsgStrings[0].s = "(None)";
3730 128 MsgStrings[0].listpos = 0;
3731 128 }
3732 128 }
3733
3734 128 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3735 {
3736
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_strings);
3737
3738 128 MsgStr tempMsgString;
3739
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 init_msgstr(&tempMsgString);
3740
3741 128 word temp_msg_count=0;
3742 word temp_expansion[16];
3743 128 memset(temp_expansion, 0, 16*sizeof(word));
3744 128 char buf[8193] = {0};
3745
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(Header->zelda_version < 0x193)
3746 {
3747 byte tempbyte;
3748 4 int32_t strings_to_read=0;
3749
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (!should_skip)
3750
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3751
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
3752 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3753 {
3754 4 strings_to_read=128;
3755 4 temp_msg_count=Header->old_str_count;
3756
3757 // Some sort of string count corruption seems to be common in old quests
3758
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(temp_msg_count>128)
3759 {
3760 temp_msg_count=128;
3761 }
3762 4 }
3763 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3764 {
3765 strings_to_read=255;
3766 temp_msg_count=Header->old_str_count;
3767 }
3768 else
3769 {
3770 if(!p_igetw(&temp_msg_count,f))
3771 {
3772 return qe_invalid;
3773 }
3774
3775 strings_to_read=temp_msg_count;
3776
3777 if (!should_skip && temp_msg_count >= msg_strings_size)
3778 {
3779 Z_message("Reallocating string buffer...\n");
3780
3781 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3782 // return qe_nomem;
3783
3784 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3785 delete[] MsgStrings;
3786 MsgStrings = new MsgStr[MAXMSGS];
3787 msg_strings_size = MAXMSGS;
3788 for(auto q = 0; q < msg_strings_size; ++q)
3789 {
3790 MsgStrings[q].clear();
3791 }
3792 }
3793 }
3794
3795 //reset the message strings
3796
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (!should_skip)
3797
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 init_msgstrings(0,msg_strings_size);
3798
3799
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t x=0; x<strings_to_read; x++)
3800 {
3801
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 init_msgstr(&tempMsgString);
3802 512 tempMsgString.listpos = x;
3803
3804
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!pfread(buf,73,f))
3805 {
3806 return qe_invalid;
3807 }
3808
3809 512 buf[74] = '\0';
3810
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 tempMsgString.s = buf;
3811
3812
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3813 {
3814 return qe_invalid;
3815 }
3816
3817
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
512 if((Header->zelda_version < 0x192)||
3818 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3819 {
3820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 tempMsgString.nextstring=tempbyte?x+1:0;
3821
3822
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3823 {
3824 return qe_invalid;
3825 }
3826
3827
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3828 {
3829 return qe_invalid;
3830 }
3831 512 }
3832 else
3833 {
3834 if(!p_igetw(&tempMsgString.nextstring,f))
3835 {
3836 return qe_invalid;
3837 }
3838
3839 if(!pfread(temp_expansion,32,f))
3840 {
3841 return qe_invalid;
3842 }
3843 }
3844
3845
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if (!should_skip)
3846
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 MsgStrings[x] = tempMsgString;
3847 512 }
3848 4 }
3849 else
3850 {
3851 int32_t dummy_int;
3852 word s_version;
3853 word s_cversion;
3854
3855 //section version info
3856
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetw(&s_version,f))
3857 {
3858 return qe_invalid;
3859 }
3860
3861 124 FFCore.quest_format[vStrings] = s_version;
3862
3863
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetw(&s_cversion,f))
3864 {
3865 return qe_invalid;
3866 }
3867
3868 //al_trace("Strings version %d\n", s_version);
3869 //section size
3870
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetl(&dummy_int,f))
3871 {
3872 return qe_invalid;
3873 }
3874
3875 //finally... section data
3876
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetw(&temp_msg_count,f))
3877 {
3878 return qe_invalid;
3879 }
3880
3881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(temp_msg_count >= msg_strings_size)
3882 {
3883 Z_message("Reallocating string buffer...\n");
3884
3885 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3886 // return qe_nomem;
3887 delete[] MsgStrings;
3888 MsgStrings = new MsgStr[MAXMSGS];
3889 msg_strings_size = MAXMSGS;
3890 for(auto q = 0; q < msg_strings_size; ++q)
3891 {
3892 MsgStrings[q].clear();
3893 }
3894 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3895 }
3896
3897 //reset the message strings
3898
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 35 times.
124 if(s_version < 7)
3899
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3900
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 init_msgstrings(0,msg_strings_size);
3901
3902 124 int32_t string_length=(s_version<2)?73:145;
3903
3904
2/2
✓ Branch 0 taken 27029 times.
✓ Branch 1 taken 124 times.
27153 for(int32_t i=0; i<temp_msg_count; i++)
3905 {
3906
1/2
✓ Branch 0 taken 27029 times.
✗ Branch 1 not taken.
27029 init_msgstr(&tempMsgString);
3907 27029 tempMsgString.listpos = i;
3908
2/2
✓ Branch 0 taken 890 times.
✓ Branch 1 taken 26139 times.
27029 if(s_version > 8)
3909 {
3910
2/4
✓ Branch 0 taken 890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
890 if(!p_igetl(&string_length,f))
3911 {
3912 return qe_invalid;
3913 }
3914 890 }
3915
3916
2/4
✓ Branch 0 taken 27029 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27029 times.
27029 if (string_length < 0 || string_length > 8193)
3917 {
3918 return qe_invalid;
3919 }
3920
3921
2/2
✓ Branch 0 taken 26891 times.
✓ Branch 1 taken 138 times.
27029 if (string_length > 0)
3922 {
3923
2/4
✓ Branch 0 taken 26891 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26891 times.
✗ Branch 3 not taken.
26891 if (!pfread(buf, string_length, f))
3924 {
3925 return qe_invalid;
3926 }
3927 26891 }
3928 else
3929 {
3930 138 buf[0] = 0;
3931 }
3932
3933
2/4
✓ Branch 0 taken 27029 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27029 times.
✗ Branch 3 not taken.
27029 if(!p_igetw(&tempMsgString.nextstring,f))
3934 {
3935 return qe_invalid;
3936 }
3937
3938
2/2
✓ Branch 0 taken 19101 times.
✓ Branch 1 taken 7928 times.
27029 if(s_version<2)
3939 {
3940 19101 buf[72] = '\0';
3941
1/2
✓ Branch 0 taken 19101 times.
✗ Branch 1 not taken.
19101 tempMsgString.s = buf;
3942 19101 }
3943 else
3944 {
3945 // June 2008: A bug corrupted the last 4 chars of a string.
3946 // Discard these.
3947
1/2
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
7928 if(s_version<3)
3948 {
3949 for(int32_t j=140; j<144; j++)
3950 {
3951 buf[j] = '\0';
3952 }
3953 }
3954
1/2
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
7928 if(string_length > 8192) string_length = 8192;
3955 7928 buf[string_length]='\0'; //Force-terminate
3956
1/2
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
7928 tempMsgString.s = buf;
3957
3958
2/2
✓ Branch 0 taken 890 times.
✓ Branch 1 taken 7038 times.
7928 if ( s_version >= 6 )
3959 {
3960
2/4
✓ Branch 0 taken 890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
890 if(!p_igetl(&tempMsgString.tile,f))
3961 {
3962 return qe_invalid;
3963 }
3964 890 }
3965 else
3966 {
3967
2/4
✓ Branch 0 taken 7038 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7038 times.
✗ Branch 3 not taken.
7038 if(!p_igetw(&tempMsgString.tile,f))
3968 {
3969 return qe_invalid;
3970 }
3971 }
3972
3973
2/4
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7928 times.
✗ Branch 3 not taken.
7928 if(!p_getc(&tempMsgString.cset,f))
3974 {
3975 return qe_invalid;
3976 }
3977
3978 byte dummy_char;
3979
3980
2/4
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7928 times.
✗ Branch 3 not taken.
7928 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
3981 {
3982 return qe_invalid;
3983 }
3984
3985 7928 tempMsgString.trans=dummy_char!=0;
3986
3987
2/4
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7928 times.
✗ Branch 3 not taken.
7928 if(!p_getc(&tempMsgString.font,f))
3988 {
3989 return qe_invalid;
3990 }
3991
3992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7928 times.
7928 if(s_version < 5)
3993 {
3994 if(!p_getc(&tempMsgString.y,f))
3995 {
3996 return qe_invalid;
3997 }
3998 }
3999 else
4000 {
4001
2/4
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7928 times.
✗ Branch 3 not taken.
7928 if(!p_igetw(&tempMsgString.x,f))
4002 {
4003 return qe_invalid;
4004 }
4005
4006
2/4
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7928 times.
✗ Branch 3 not taken.
7928 if(!p_igetw(&tempMsgString.y,f))
4007 {
4008 return qe_invalid;
4009 }
4010
4011
2/4
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7928 times.
✗ Branch 3 not taken.
7928 if(!p_igetw(&tempMsgString.w,f))
4012 {
4013 return qe_invalid;
4014 }
4015
4016
2/4
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7928 times.
✗ Branch 3 not taken.
7928 if(!p_igetw(&tempMsgString.h,f))
4017 {
4018 return qe_invalid;
4019 }
4020
4021
2/4
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7928 times.
✗ Branch 3 not taken.
7928 if(!p_getc(&tempMsgString.hspace,f))
4022 {
4023 return qe_invalid;
4024 }
4025
4026
2/4
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7928 times.
✗ Branch 3 not taken.
7928 if(!p_getc(&tempMsgString.vspace,f))
4027 {
4028 return qe_invalid;
4029 }
4030
4031
2/4
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7928 times.
✗ Branch 3 not taken.
7928 if(!p_getc(&tempMsgString.stringflags,f))
4032 {
4033 return qe_invalid;
4034 }
4035 }
4036
4037
2/2
✓ Branch 0 taken 7038 times.
✓ Branch 1 taken 890 times.
7928 if(s_version >= 7)
4038 {
4039
2/2
✓ Branch 0 taken 890 times.
✓ Branch 1 taken 3560 times.
4450 for(int32_t q = 0; q < 4; ++q)
4040 {
4041
2/4
✓ Branch 0 taken 3560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3560 times.
✗ Branch 3 not taken.
3560 if(!p_getc(&tempMsgString.margins[q],f))
4042 {
4043 return qe_invalid;
4044 }
4045 3560 }
4046
4047
2/4
✓ Branch 0 taken 890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
890 if(!p_igetl(&tempMsgString.portrait_tile,f))
4048 {
4049 return qe_invalid;
4050 }
4051
4052
2/4
✓ Branch 0 taken 890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
890 if(!p_getc(&tempMsgString.portrait_cset,f))
4053 {
4054 return qe_invalid;
4055 }
4056
4057
2/4
✓ Branch 0 taken 890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
890 if(!p_getc(&tempMsgString.portrait_x,f))
4058 {
4059 return qe_invalid;
4060 }
4061
4062
2/4
✓ Branch 0 taken 890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
890 if(!p_getc(&tempMsgString.portrait_y,f))
4063 {
4064 return qe_invalid;
4065 }
4066
4067
2/4
✓ Branch 0 taken 890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
890 if(!p_getc(&tempMsgString.portrait_tw,f))
4068 {
4069 return qe_invalid;
4070 }
4071
4072
2/4
✓ Branch 0 taken 890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
890 if(!p_getc(&tempMsgString.portrait_th,f))
4073 {
4074 return qe_invalid;
4075 }
4076 890 }
4077
4078
2/2
✓ Branch 0 taken 890 times.
✓ Branch 1 taken 7038 times.
7928 if(s_version >= 8)
4079 {
4080
2/4
✓ Branch 0 taken 890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
890 if(!p_getc(&tempMsgString.shadow_type,f))
4081 {
4082 return qe_invalid;
4083 }
4084
4085
2/4
✓ Branch 0 taken 890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
890 if(!p_getc(&tempMsgString.shadow_color,f))
4086 {
4087 return qe_invalid;
4088 }
4089 890 }
4090
4091
2/2
✓ Branch 0 taken 773 times.
✓ Branch 1 taken 7155 times.
7928 if(s_version >= 10)
4092 {
4093
2/4
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 773 times.
✗ Branch 3 not taken.
773 if(!p_getc(&tempMsgString.drawlayer,f))
4094 {
4095 return qe_invalid;
4096 }
4097 773 }
4098
4099
2/4
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7928 times.
✗ Branch 3 not taken.
7928 if(!p_getc(&tempMsgString.sfx,f))
4100 {
4101 return qe_invalid;
4102 }
4103
4104
1/2
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
7928 if(s_version>3)
4105 {
4106
2/4
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7928 times.
✗ Branch 3 not taken.
7928 if(!p_igetw(&tempMsgString.listpos,f))
4107 {
4108 return qe_invalid;
4109 }
4110 7928 }
4111 }
4112
4113
1/2
✓ Branch 0 taken 27029 times.
✗ Branch 1 not taken.
27029 MsgStrings[i].copyAll(tempMsgString);
4114 27029 }
4115 }
4116
4117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (!should_skip)
4118 128 msg_count=temp_msg_count;
4119
4120 128 return 0;
4121 128 }
4122
4123 128 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
4124 {
4125
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_doors);
4126
4127
2/4
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
128 if((Header->zelda_version < 0x192)||
4128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4129 {
4130 4 return 0;
4131 }
4132
4133 124 word temp_door_combo_set_count=0;
4134 DoorComboSet tempDoorComboSet;
4135 word dummy_word;
4136 int32_t dummy_long;
4137 byte padding;
4138 124 int32_t s_version = 0;
4139
4140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if (!should_skip)
4141
2/2
✓ Branch 0 taken 31744 times.
✓ Branch 1 taken 124 times.
31868 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4142 {
4143 31744 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4144 31868 }
4145
4146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(Header->zelda_version > 0x192)
4147 {
4148 //section version info
4149
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&s_version,f))
4150 {
4151 return qe_invalid;
4152 }
4153
4154 124 FFCore.quest_format[vDoors] = s_version;
4155
4156 //al_trace("Door combo sets version %d\n", dummy_word);
4157
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&dummy_word,f))
4158 {
4159 return qe_invalid;
4160 }
4161
4162 //section size
4163
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&dummy_long,f))
4164 {
4165 return qe_invalid;
4166 }
4167 124 }
4168
4169 //finally... section data
4170
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&temp_door_combo_set_count,f))
4171 {
4172 return qe_invalid;
4173 }
4174
4175
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
124 if (!(temp_door_combo_set_count >= 0 && temp_door_combo_set_count <= MAXDOORCOMBOSETS))
4176 {
4177 return qe_invalid;
4178 }
4179
4180
2/2
✓ Branch 0 taken 994 times.
✓ Branch 1 taken 124 times.
1118 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4181 {
4182 994 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4183
4184 //name
4185
1/2
✓ Branch 0 taken 994 times.
✗ Branch 1 not taken.
994 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f))
4186 {
4187 return qe_invalid;
4188 }
4189
4190
1/2
✓ Branch 0 taken 994 times.
✗ Branch 1 not taken.
994 if(Header->zelda_version < 0x193)
4191 {
4192 if(!p_getc(&padding,f))
4193 {
4194 return qe_invalid;
4195 }
4196 }
4197
4198 //up door
4199
2/2
✓ Branch 0 taken 8946 times.
✓ Branch 1 taken 994 times.
9940 for(int32_t j=0; j<9; j++)
4200 {
4201
2/2
✓ Branch 0 taken 35784 times.
✓ Branch 1 taken 8946 times.
44730 for(int32_t k=0; k<4; k++)
4202 {
4203
1/2
✓ Branch 0 taken 35784 times.
✗ Branch 1 not taken.
35784 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
4204 {
4205 return qe_invalid;
4206 }
4207 35784 }
4208 8946 }
4209
4210
2/2
✓ Branch 0 taken 8946 times.
✓ Branch 1 taken 994 times.
9940 for(int32_t j=0; j<9; j++)
4211 {
4212
2/2
✓ Branch 0 taken 35784 times.
✓ Branch 1 taken 8946 times.
44730 for(int32_t k=0; k<4; k++)
4213 {
4214
1/2
✓ Branch 0 taken 35784 times.
✗ Branch 1 not taken.
35784 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4215 {
4216 return qe_invalid;
4217 }
4218 35784 }
4219 8946 }
4220
4221 //down door
4222
2/2
✓ Branch 0 taken 8946 times.
✓ Branch 1 taken 994 times.
9940 for(int32_t j=0; j<9; j++)
4223 {
4224
2/2
✓ Branch 0 taken 35784 times.
✓ Branch 1 taken 8946 times.
44730 for(int32_t k=0; k<4; k++)
4225 {
4226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35784 times.
35784 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4227 {
4228 return qe_invalid;
4229 }
4230 35784 }
4231 8946 }
4232
4233
2/2
✓ Branch 0 taken 8946 times.
✓ Branch 1 taken 994 times.
9940 for(int32_t j=0; j<9; j++)
4234 {
4235
2/2
✓ Branch 0 taken 35784 times.
✓ Branch 1 taken 8946 times.
44730 for(int32_t k=0; k<4; k++)
4236 {
4237
1/2
✓ Branch 0 taken 35784 times.
✗ Branch 1 not taken.
35784 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4238 {
4239 return qe_invalid;
4240 }
4241 35784 }
4242 8946 }
4243
4244 //left door
4245
2/2
✓ Branch 0 taken 8946 times.
✓ Branch 1 taken 994 times.
9940 for(int32_t j=0; j<9; j++)
4246 {
4247
2/2
✓ Branch 0 taken 53676 times.
✓ Branch 1 taken 8946 times.
62622 for(int32_t k=0; k<6; k++)
4248 {
4249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53676 times.
53676 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4250 {
4251 return qe_invalid;
4252 }
4253 53676 }
4254 8946 }
4255
4256
2/2
✓ Branch 0 taken 8946 times.
✓ Branch 1 taken 994 times.
9940 for(int32_t j=0; j<9; j++)
4257 {
4258
2/2
✓ Branch 0 taken 53676 times.
✓ Branch 1 taken 8946 times.
62622 for(int32_t k=0; k<6; k++)
4259 {
4260
1/2
✓ Branch 0 taken 53676 times.
✗ Branch 1 not taken.
53676 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4261 {
4262 return qe_invalid;
4263 }
4264 53676 }
4265 8946 }
4266
4267 //right door
4268
2/2
✓ Branch 0 taken 8946 times.
✓ Branch 1 taken 994 times.
9940 for(int32_t j=0; j<9; j++)
4269 {
4270
2/2
✓ Branch 0 taken 53676 times.
✓ Branch 1 taken 8946 times.
62622 for(int32_t k=0; k<6; k++)
4271 {
4272
1/2
✓ Branch 0 taken 53676 times.
✗ Branch 1 not taken.
53676 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4273 {
4274 return qe_invalid;
4275 }
4276 53676 }
4277 8946 }
4278
4279
2/2
✓ Branch 0 taken 8946 times.
✓ Branch 1 taken 994 times.
9940 for(int32_t j=0; j<9; j++)
4280 {
4281
2/2
✓ Branch 0 taken 53676 times.
✓ Branch 1 taken 8946 times.
62622 for(int32_t k=0; k<6; k++)
4282 {
4283
1/2
✓ Branch 0 taken 53676 times.
✗ Branch 1 not taken.
53676 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4284 {
4285 return qe_invalid;
4286 }
4287 53676 }
4288 8946 }
4289
4290 //up bomb rubble
4291
2/2
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 994 times.
2982 for(int32_t j=0; j<2; j++)
4292 {
4293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1988 times.
1988 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4294 {
4295 return qe_invalid;
4296 }
4297 1988 }
4298
4299
2/2
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 994 times.
2982 for(int32_t j=0; j<2; j++)
4300 {
4301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1988 times.
1988 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4302 {
4303 return qe_invalid;
4304 }
4305 1988 }
4306
4307 //down bomb rubble
4308
2/2
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 994 times.
2982 for(int32_t j=0; j<2; j++)
4309 {
4310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1988 times.
1988 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4311 {
4312 return qe_invalid;
4313 }
4314 1988 }
4315
4316
2/2
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 994 times.
2982 for(int32_t j=0; j<2; j++)
4317 {
4318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1988 times.
1988 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4319 {
4320 return qe_invalid;
4321 }
4322 1988 }
4323
4324 //left bomb rubble
4325
2/2
✓ Branch 0 taken 2982 times.
✓ Branch 1 taken 994 times.
3976 for(int32_t j=0; j<3; j++)
4326 {
4327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2982 times.
2982 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4328 {
4329 return qe_invalid;
4330 }
4331 2982 }
4332
4333
2/2
✓ Branch 0 taken 2982 times.
✓ Branch 1 taken 994 times.
3976 for(int32_t j=0; j<3; j++)
4334 {
4335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2982 times.
2982 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4336 {
4337 return qe_invalid;
4338 }
4339 2982 }
4340
4341
1/2
✓ Branch 0 taken 994 times.
✗ Branch 1 not taken.
994 if(Header->zelda_version < 0x193)
4342 {
4343 if(!p_getc(&padding,f))
4344 {
4345 return qe_invalid;
4346 }
4347
4348 }
4349
4350 //right bomb rubble
4351
2/2
✓ Branch 0 taken 2982 times.
✓ Branch 1 taken 994 times.
3976 for(int32_t j=0; j<3; j++)
4352 {
4353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2982 times.
2982 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4354 {
4355 return qe_invalid;
4356 }
4357 2982 }
4358
4359
2/2
✓ Branch 0 taken 2982 times.
✓ Branch 1 taken 994 times.
3976 for(int32_t j=0; j<3; j++)
4360 {
4361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2982 times.
2982 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4362 {
4363 return qe_invalid;
4364 }
4365 2982 }
4366
4367
1/2
✓ Branch 0 taken 994 times.
✗ Branch 1 not taken.
994 if(Header->zelda_version < 0x193)
4368 {
4369 if(!p_getc(&padding,f))
4370 {
4371 return qe_invalid;
4372 }
4373 }
4374
4375 //walkthrough stuff
4376
2/2
✓ Branch 0 taken 3976 times.
✓ Branch 1 taken 994 times.
4970 for(int32_t j=0; j<4; j++)
4377 {
4378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3976 times.
3976 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4379 {
4380 return qe_invalid;
4381 }
4382 3976 }
4383
4384
2/2
✓ Branch 0 taken 3976 times.
✓ Branch 1 taken 994 times.
4970 for(int32_t j=0; j<4; j++)
4385 {
4386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3976 times.
3976 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4387 {
4388 return qe_invalid;
4389 }
4390 3976 }
4391
4392 //flags
4393
2/2
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 994 times.
2982 for(int32_t j=0; j<2; j++)
4394 {
4395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1988 times.
1988 if(!p_getc(&tempDoorComboSet.flags[j],f))
4396 {
4397 return qe_invalid;
4398 }
4399 1988 }
4400
4401
1/2
✓ Branch 0 taken 994 times.
✗ Branch 1 not taken.
994 if(Header->zelda_version < 0x193)
4402 {
4403 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4404 {
4405 return qe_invalid;
4406 }
4407 }
4408
4409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 994 times.
994 if (!should_skip)
4410 994 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4411 994 }
4412
4413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if (!should_skip)
4414 124 door_combo_set_count=temp_door_combo_set_count;
4415
4416 124 return 0;
4417 128 }
4418
4419 int32_t count_dmaps()
4420 {
4421 int32_t i=MAXDMAPS-1;
4422 bool found=false;
4423
4424 while(i>=0 && !found)
4425 {
4426 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4427 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4428 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4429 found=true;
4430
4431 for(int32_t j=0; j<8; j++)
4432 {
4433 if(DMaps[i].grid[j]!=0)
4434
4435 found=true;
4436 }
4437
4438 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4439 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4440 found=true;
4441
4442 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4443 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4444 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4445 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4446 found=true;
4447
4448 if(!found)
4449 {
4450 i--;
4451 }
4452 }
4453
4454 return i+1;
4455 }
4456
4457
4458 int32_t count_shops(miscQdata *Misc)
4459 {
4460 int32_t i=NUM_SHOPS-1,j;
4461 bool found=false;
4462
4463 while(i>=0 && !found)
4464 {
4465 j=2;
4466
4467 while(j>=0 && !found)
4468 {
4469 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4470 {
4471 found=true;
4472 }
4473 else
4474 {
4475 j--;
4476 }
4477 }
4478
4479 if(Misc->shop[i].name[0]!=0)
4480 {
4481 found=true;
4482 }
4483
4484 if(!found)
4485 {
4486 i--;
4487 }
4488 }
4489
4490 return i+1;
4491 }
4492
4493 int32_t count_infos(miscQdata *Misc)
4494 {
4495 int32_t i=255,j;
4496 bool found=false;
4497
4498 while(i>=0 && !found)
4499 {
4500 j=2;
4501
4502 while(j>=0 && !found)
4503 {
4504 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4505 {
4506 found=true;
4507 }
4508 else
4509 {
4510 j--;
4511 }
4512 }
4513
4514 if(Misc->info[i].name[0]!=0)
4515 {
4516 found=true;
4517 }
4518
4519 if(!found)
4520 {
4521 i--;
4522 }
4523 }
4524
4525 return i+1;
4526 }
4527
4528 int32_t count_warprings(miscQdata *Misc)
4529 {
4530 int32_t i=15,j;
4531 bool found=false;
4532
4533 while(i>=0 && !found)
4534 {
4535 j=7;
4536
4537 while(j>=0 && !found)
4538 {
4539 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4540 {
4541 found=true;
4542 }
4543 else
4544 {
4545 j--;
4546 }
4547 }
4548
4549 if(!found)
4550 {
4551 i--;
4552 }
4553 }
4554
4555 return i+1;
4556 }
4557
4558 int32_t count_palcycles(miscQdata *Misc)
4559 {
4560 int32_t i=255,j;
4561 bool found=false;
4562
4563 while(i>=0 && !found)
4564 {
4565 j=2;
4566
4567 while(j>=0 && !found)
4568 {
4569 if(Misc->cycles[i][j].count!=0)
4570 {
4571 found=true;
4572 }
4573 else
4574 {
4575 j--;
4576 }
4577 }
4578
4579 if(!found)
4580 {
4581 i--;
4582 }
4583 }
4584
4585 return i+1;
4586 }
4587
4588 264440 void clear_screen(mapscr *temp_scr)
4589 {
4590 264440 temp_scr->zero_memory();
4591 264440 }
4592
4593 128 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
4594 {
4595
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_dmaps);
4596
4597 128 word dmapstoread=0;
4598 128 dmap tempDMap;
4599
4600 int32_t dummy;
4601 128 word s_version=0, s_cversion=0;
4602 byte padding;
4603
4604 char legacy_title[21];
4605
4606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (!should_skip)
4607
2/2
✓ Branch 0 taken 65536 times.
✓ Branch 1 taken 128 times.
65664 for(int32_t i=0; i<max_dmaps; i++)
4608 {
4609
1/2
✓ Branch 0 taken 65536 times.
✗ Branch 1 not taken.
65536 DMaps[start_dmap + i].clear();
4610 65536 sprintf(legacy_title," ");
4611 65536 sprintf(DMaps[start_dmap+i].intro," ");
4612 65536 DMaps[start_dmap+i].type |= dmCAVE;
4613 65664 }
4614
4615
3/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✓ Branch 3 taken 4 times.
128 if(!Header || Header->zelda_version > 0x192)
4616 {
4617 //section version info
4618
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetw(&s_version,f))
4619 {
4620 return qe_invalid;
4621 }
4622
4623 124 FFCore.quest_format[vDMaps] = s_version;
4624
4625 //al_trace("DMaps version %d\n", s_version);
4626
4627
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetw(&s_cversion,f))
4628 {
4629 return qe_invalid;
4630 }
4631
4632 //section size
4633
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetl(&dummy,f))
4634 {
4635 return qe_invalid;
4636 }
4637
4638 //finally... section data
4639
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetw(&dmapstoread,f))
4640 {
4641 return qe_invalid;
4642 }
4643 124 }
4644 else
4645 {
4646
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
4647 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4648 {
4649 4 dmapstoread=32;
4650 4 }
4651 else if(s_version <= 4)
4652 {
4653 dmapstoread=OLDMAXDMAPS;
4654 }
4655 else
4656 {
4657 dmapstoread=MAXDMAPS;
4658 }
4659 }
4660
4661
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 112 times.
128 dmapstoread=zc_min(dmapstoread, max_dmaps);
4662
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 112 times.
128 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4663
4664
2/2
✓ Branch 0 taken 60544 times.
✓ Branch 1 taken 128 times.
60672 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4665 {
4666
1/2
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
60544 tempDMap.clear();
4667 60544 sprintf(legacy_title," ");
4668 60544 sprintf(tempDMap.intro," ");
4669
4670
2/4
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60544 times.
✗ Branch 3 not taken.
60544 if(!p_getc(&tempDMap.map,f))
4671 {
4672 return qe_invalid;
4673 }
4674
4675
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 57344 times.
60544 if(s_version <= 4)
4676 {
4677 byte tempbyte;
4678
4679
2/4
✓ Branch 0 taken 3200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3200 times.
✗ Branch 3 not taken.
3200 if(!p_getc(&tempbyte,f))
4680 {
4681 return qe_invalid;
4682 }
4683
4684 3200 tempDMap.level=(word)tempbyte;
4685 3200 }
4686 else
4687 {
4688
2/4
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57344 times.
✗ Branch 3 not taken.
57344 if(!p_igetw(&tempDMap.level,f))
4689 {
4690 return qe_invalid;
4691 }
4692 }
4693
4694
2/4
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60544 times.
✗ Branch 3 not taken.
60544 if(!p_getc(&tempDMap.xoff,f))
4695 {
4696 return qe_invalid;
4697 }
4698
4699
2/4
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60544 times.
✗ Branch 3 not taken.
60544 if(!p_getc(&tempDMap.compass,f))
4700 {
4701 return qe_invalid;
4702 }
4703
4704
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 3200 times.
60544 if(s_version > 8) // February 2009
4705 {
4706
2/4
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57344 times.
✗ Branch 3 not taken.
57344 if(!p_igetw(&tempDMap.color,f))
4707 {
4708 return qe_invalid;
4709 }
4710 57344 }
4711 else
4712 {
4713 byte tempbyte;
4714
4715
2/4
✓ Branch 0 taken 3200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3200 times.
✗ Branch 3 not taken.
3200 if(!p_getc(&tempbyte,f))
4716 {
4717 return qe_invalid;
4718 }
4719
4720 3200 tempDMap.color = (word)tempbyte;
4721 }
4722
4723
2/4
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60544 times.
✗ Branch 3 not taken.
60544 if(!p_getc(&tempDMap.midi,f))
4724 {
4725 return qe_invalid;
4726 }
4727
4728
2/4
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60544 times.
✗ Branch 3 not taken.
60544 if(!p_getc(&tempDMap.cont,f))
4729 {
4730 return qe_invalid;
4731 }
4732
4733
2/4
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60544 times.
✗ Branch 3 not taken.
60544 if(!p_getc(&tempDMap.type,f))
4734 {
4735 return qe_invalid;
4736 }
4737
4738
4/4
✓ Branch 0 taken 828 times.
✓ Branch 1 taken 59716 times.
✓ Branch 2 taken 816 times.
✓ Branch 3 taken 12 times.
61372 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4739
1/2
✓ Branch 0 taken 828 times.
✗ Branch 1 not taken.
828 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4740 816 tempDMap.xoff = 0;
4741
4742
2/2
✓ Branch 0 taken 60544 times.
✓ Branch 1 taken 484352 times.
544896 for(int32_t j=0; j<8; j++)
4743 {
4744
2/4
✓ Branch 0 taken 484352 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 484352 times.
✗ Branch 3 not taken.
484352 if(!p_getc(&tempDMap.grid[j],f))
4745 {
4746 return qe_invalid;
4747 }
4748 484352 }
4749
4750
4/6
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60416 times.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60416 times.
60544 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4751 {
4752
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
128 if(tempDMap.level>0&&tempDMap.level<10)
4753 {
4754 38 sprintf(legacy_title,"LEVEL-%d ", tempDMap.level);
4755 38 }
4756
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 tempDMap.title.assign(legacy_title);
4757
4758
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
128 if(i==0 && Header->zelda_version <= 0x190)
4759 {
4760 4 tempDMap.cont-=tempDMap.xoff;
4761 4 tempDMap.compass-=tempDMap.xoff;
4762 4 }
4763
4764 //forgotten -DD
4765
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
128 if(tempDMap.level==0)
4766 {
4767 90 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4768 90 }
4769 128 }
4770 else
4771 {
4772
2/4
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60416 times.
✗ Branch 3 not taken.
60416 if(!pfread(&tempDMap.name,sizeof(DMaps[0].name),f))
4773 {
4774 return qe_invalid;
4775 }
4776
4777
1/2
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
60416 if(s_version<20)
4778 {
4779
2/4
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60416 times.
✗ Branch 3 not taken.
60416 if (!pfread(&legacy_title, sizeof(legacy_title), f))
4780 {
4781 return qe_invalid;
4782 }
4783
1/2
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
60416 tempDMap.title.assign(legacy_title);
4784 60416 }
4785 else
4786 {
4787 std::string tmptitle;
4788 if (!p_getwstr(&tmptitle, f))
4789 {
4790 return qe_invalid;
4791 }
4792 tempDMap.title.reserve(tmptitle.size());
4793 tempDMap.title = tmptitle;
4794 }
4795
4796
2/4
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60416 times.
✗ Branch 3 not taken.
60416 if(!pfread(&tempDMap.intro,sizeof(DMaps[0].intro),f))
4797 {
4798 return qe_invalid;
4799 }
4800
4801
3/8
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60416 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 60416 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
60416 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4802 {
4803 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4804 DMaps[i] = tempDMap;
4805
4806 continue;
4807 }
4808
4809
2/4
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 60416 times.
60416 if(Header && (Header->zelda_version < 0x193))
4810 {
4811 if(!p_getc(&padding,f))
4812 {
4813 return qe_invalid;
4814 }
4815 }
4816
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 42496 times.
60416 if ( s_version >= 11 )
4817 {
4818
2/4
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17920 times.
✗ Branch 3 not taken.
17920 if(!p_igetl(&tempDMap.minimap_1_tile,f))
4819 {
4820 return qe_invalid;
4821 }
4822 17920 }
4823 else
4824 {
4825
2/4
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42496 times.
✗ Branch 3 not taken.
42496 if(!p_igetw(&tempDMap.minimap_1_tile,f))
4826 {
4827 return qe_invalid;
4828 }
4829 }
4830
4831
2/4
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60416 times.
✗ Branch 3 not taken.
60416 if(!p_getc(&tempDMap.minimap_1_cset,f))
4832 {
4833 return qe_invalid;
4834 }
4835
4836
2/4
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 60416 times.
60416 if(Header && (Header->zelda_version < 0x193))
4837 {
4838 if(!p_getc(&padding,f))
4839 {
4840 return qe_invalid;
4841 }
4842 }
4843
4844
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 42496 times.
60416 if ( s_version >= 11 )
4845 {
4846
2/4
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17920 times.
✗ Branch 3 not taken.
17920 if(!p_igetl(&tempDMap.minimap_2_tile,f))
4847 {
4848 return qe_invalid;
4849 }
4850 17920 }
4851 else
4852 {
4853
2/4
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42496 times.
✗ Branch 3 not taken.
42496 if(!p_igetw(&tempDMap.minimap_2_tile,f))
4854 {
4855 return qe_invalid;
4856 }
4857 }
4858
2/4
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60416 times.
✗ Branch 3 not taken.
60416 if(!p_getc(&tempDMap.minimap_2_cset,f))
4859 {
4860 return qe_invalid;
4861 }
4862
4863
2/4
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 60416 times.
60416 if(Header && (Header->zelda_version < 0x193))
4864 {
4865 if(!p_getc(&padding,f))
4866 {
4867 return qe_invalid;
4868 }
4869 }
4870
4871
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 42496 times.
60416 if ( s_version >= 11 )
4872 {
4873
2/4
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17920 times.
17920 if(!p_igetl(&tempDMap.largemap_1_tile,f))
4874 {
4875 return qe_invalid;
4876 }
4877 17920 }
4878 else
4879 {
4880
2/4
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42496 times.
42496 if(!p_igetw(&tempDMap.largemap_1_tile,f))
4881 {
4882 return qe_invalid;
4883 }
4884 }
4885
4886
2/4
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60416 times.
✗ Branch 3 not taken.
60416 if(!p_getc(&tempDMap.largemap_1_cset,f))
4887 {
4888 return qe_invalid;
4889 }
4890
4891
2/4
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 60416 times.
60416 if(Header && (Header->zelda_version < 0x193))
4892 {
4893
4894 if(!p_getc(&padding,f))
4895 {
4896 return qe_invalid;
4897 }
4898 }
4899
4900
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 42496 times.
60416 if ( s_version >= 11 )
4901 {
4902
2/4
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17920 times.
✗ Branch 3 not taken.
17920 if(!p_igetl(&tempDMap.largemap_2_tile,f))
4903 {
4904 return qe_invalid;
4905 }
4906 17920 }
4907 else
4908 {
4909
2/4
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42496 times.
✗ Branch 3 not taken.
42496 if(!p_igetw(&tempDMap.largemap_2_tile,f))
4910 {
4911 return qe_invalid;
4912 }
4913 }
4914
2/4
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60416 times.
✗ Branch 3 not taken.
60416 if(!p_getc(&tempDMap.largemap_2_cset,f))
4915 {
4916 return qe_invalid;
4917 }
4918
4919
2/4
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60416 times.
✗ Branch 3 not taken.
60416 if(!pfread(&tempDMap.tmusic,sizeof(DMaps[0].tmusic),f))
4920 {
4921 return qe_invalid;
4922 }
4923 }
4924
4925
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 3200 times.
60544 if(s_version>1)
4926 {
4927
2/4
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57344 times.
✗ Branch 3 not taken.
57344 if(!p_getc(&tempDMap.tmusictrack,f))
4928 {
4929 return qe_invalid;
4930 }
4931
4932
2/4
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57344 times.
✗ Branch 3 not taken.
57344 if(!p_getc(&tempDMap.active_subscreen,f))
4933 {
4934 return qe_invalid;
4935 }
4936
4937
2/4
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57344 times.
✗ Branch 3 not taken.
57344 if(!p_getc(&tempDMap.passive_subscreen,f))
4938 {
4939 return qe_invalid;
4940 }
4941 57344 }
4942
4943
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 3200 times.
60544 if(s_version>2)
4944 {
4945 byte di[32];
4946
4947
2/4
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57344 times.
✗ Branch 3 not taken.
57344 if(!pfread(&di, 32, f)) return qe_invalid;
4948
4949
2/2
✓ Branch 0 taken 14680064 times.
✓ Branch 1 taken 57344 times.
14737408 for(int32_t j=0; j<MAXITEMS; j++)
4950 {
4951
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 14680057 times.
14680064 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4952 14680057 else tempDMap.disableditems[j]=0;
4953 14680064 }
4954 57344 }
4955
4956
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 3200 times.
60544 if(s_version >= 6)
4957 {
4958
2/4
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57344 times.
✗ Branch 3 not taken.
57344 if(!p_igetl(&tempDMap.flags,f))
4959 {
4960 return qe_invalid;
4961 }
4962 57344 }
4963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3200 times.
3200 else if(s_version>3)
4964 {
4965 char temp;
4966
4967 if(!p_getc(&temp,f))
4968 {
4969 return qe_invalid;
4970 }
4971
4972 tempDMap.flags = temp;
4973 }
4974
3/8
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 816 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3200 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4975 {
4976 816 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4977 816 }
4978 else
4979 2384 tempDMap.flags=0;
4980
4981
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 3200 times.
60544 if(s_version<7)
4982 {
4983
4/6
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✓ Branch 2 taken 816 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 816 times.
3200 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4984 816 tempDMap.flags|= dmfVIEWMAP;
4985 3200 }
4986
4987
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 3200 times.
60544 if(s_version<8)
4988 {
4989
4/4
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✓ Branch 2 taken 207 times.
✓ Branch 3 taken 609 times.
3200 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4990 {
4991 609 tempDMap.type &= ~dmDNGN;
4992 609 tempDMap.type |= dmCAVE;
4993 609 }
4994
2/2
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 1736 times.
2591 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4995 {
4996 1736 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4997 1736 }
4998 3200 }
4999
5000
5/8
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 60416 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 128 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 60416 times.
60544 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
5001 60416 && (Header->zelda_version < 0x193))
5002 {
5003 if(!p_getc(&padding,f))
5004 {
5005 return qe_invalid;
5006 }
5007 }
5008
5009
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 17920 times.
60544 if(s_version >= 10)
5010 {
5011
2/4
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17920 times.
✗ Branch 3 not taken.
17920 if(!p_getc(&tempDMap.sideview,f))
5012 {
5013 return qe_invalid;
5014 }
5015 17920 }
5016
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 42624 times.
60544 if(s_version < 10) tempDMap.sideview = 0;
5017
5018 //Dmap Scripts
5019
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 42624 times.
60544 if(s_version >= 12)
5020 {
5021
2/4
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17920 times.
✗ Branch 3 not taken.
17920 if(!p_igetw(&tempDMap.script,f))
5022 {
5023 return qe_invalid;
5024 }
5025
2/2
✓ Branch 0 taken 143360 times.
✓ Branch 1 taken 17920 times.
161280 for ( int32_t q = 0; q < 8; q++ )
5026 {
5027
2/4
✓ Branch 0 taken 143360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 143360 times.
✗ Branch 3 not taken.
143360 if(!p_igetl(&tempDMap.initD[q],f))
5028 {
5029 return qe_invalid;
5030 }
5031 143360 }
5032 17920 }
5033
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 42624 times.
60544 if ( s_version < 12 )
5034 {
5035 42624 tempDMap.script = 0;
5036
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for ( int32_t q = 0; q < 8; q++ )
5037 {
5038 340992 tempDMap.initD[q] = 0;
5039 340992 }
5040 42624 }
5041
5042
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 17920 times.
60544 if(s_version >= 13)
5043 {
5044
2/2
✓ Branch 0 taken 143360 times.
✓ Branch 1 taken 17920 times.
161280 for ( int32_t q = 0; q < 8; q++ )
5045 {
5046
2/2
✓ Branch 0 taken 9318400 times.
✓ Branch 1 taken 143360 times.
9461760 for ( int32_t w = 0; w < 65; w++ )
5047 {
5048
2/4
✓ Branch 0 taken 9318400 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9318400 times.
✗ Branch 3 not taken.
9318400 if(!p_getc(&tempDMap.initD_label[q][w],f))
5049 {
5050 return qe_invalid;
5051 }
5052 9318400 }
5053 143360 }
5054 17920 }
5055
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 42624 times.
60544 if ( s_version < 13 )
5056 {
5057 42624 tempDMap.script = 0;
5058
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for ( int32_t q = 0; q < 8; q++ )
5059 {
5060
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for ( int32_t w = 0; w < 65; w++ )
5061 22164480 tempDMap.initD_label[q][w] = 0;
5062 340992 }
5063 42624 }
5064
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 42624 times.
60544 if(s_version >= 14)
5065 {
5066
2/4
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17920 times.
✗ Branch 3 not taken.
17920 if(!p_igetw(&tempDMap.active_sub_script,f))
5067 {
5068 return qe_invalid;
5069 }
5070
2/4
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17920 times.
✗ Branch 3 not taken.
17920 if(!p_igetw(&tempDMap.passive_sub_script,f))
5071 {
5072 return qe_invalid;
5073 }
5074
2/2
✓ Branch 0 taken 143360 times.
✓ Branch 1 taken 17920 times.
161280 for ( int32_t q = 0; q < 8; ++q )
5075 {
5076
2/4
✓ Branch 0 taken 143360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 143360 times.
✗ Branch 3 not taken.
143360 if(!p_igetl(&tempDMap.sub_initD[q],f))
5077 {
5078 return qe_invalid;
5079 }
5080 143360 }
5081
2/2
✓ Branch 0 taken 143360 times.
✓ Branch 1 taken 17920 times.
161280 for(int32_t q = 0; q < 8; ++q)
5082 {
5083
2/2
✓ Branch 0 taken 9318400 times.
✓ Branch 1 taken 143360 times.
9461760 for ( int32_t w = 0; w < 65; ++w )
5084 {
5085
2/4
✓ Branch 0 taken 9318400 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9318400 times.
✗ Branch 3 not taken.
9318400 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
5086 {
5087 return qe_invalid;
5088 }
5089 9318400 }
5090 143360 }
5091 17920 }
5092 else
5093 {
5094 42624 tempDMap.active_sub_script = 0;
5095 42624 tempDMap.passive_sub_script = 0;
5096
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for(int32_t q = 0; q < 8; ++q)
5097 {
5098 340992 tempDMap.sub_initD[q] = 0;
5099
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for(int32_t w = 0; w < 65; ++w)
5100 22164480 tempDMap.sub_initD_label[q][w] = 0;
5101 340992 }
5102 }
5103
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 42624 times.
60544 if(s_version >= 15)
5104 {
5105
2/4
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17920 times.
✗ Branch 3 not taken.
17920 if(!p_igetw(&tempDMap.onmap_script,f))
5106 {
5107 return qe_invalid;
5108 }
5109
2/2
✓ Branch 0 taken 143360 times.
✓ Branch 1 taken 17920 times.
161280 for ( int32_t q = 0; q < 8; ++q )
5110 {
5111
2/4
✓ Branch 0 taken 143360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 143360 times.
✗ Branch 3 not taken.
143360 if(!p_igetl(&tempDMap.onmap_initD[q],f))
5112 {
5113 return qe_invalid;
5114 }
5115 143360 }
5116
2/2
✓ Branch 0 taken 143360 times.
✓ Branch 1 taken 17920 times.
161280 for(int32_t q = 0; q < 8; ++q)
5117 {
5118
2/2
✓ Branch 0 taken 9318400 times.
✓ Branch 1 taken 143360 times.
9461760 for ( int32_t w = 0; w < 65; ++w )
5119 {
5120
2/4
✓ Branch 0 taken 9318400 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9318400 times.
✗ Branch 3 not taken.
9318400 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
5121 {
5122 return qe_invalid;
5123 }
5124 9318400 }
5125 143360 }
5126 17920 }
5127 else
5128 {
5129 42624 tempDMap.onmap_script = 0;
5130
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for(int32_t q = 0; q < 8; ++q)
5131 {
5132 340992 tempDMap.onmap_initD[q] = 0;
5133
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for(int32_t w = 0; w < 65; ++w)
5134 {
5135 22164480 tempDMap.onmap_initD_label[q][w] = 0;
5136 22164480 }
5137 340992 }
5138 }
5139
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 42624 times.
60544 if(s_version >= 16)
5140 {
5141
2/4
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17920 times.
✗ Branch 3 not taken.
17920 if(!p_igetw(&tempDMap.mirrorDMap,f))
5142 {
5143 return qe_invalid;
5144 }
5145 17920 }
5146 else
5147 {
5148 42624 tempDMap.mirrorDMap = -1;
5149 }
5150
5151
2/2
✓ Branch 0 taken 47232 times.
✓ Branch 1 taken 13312 times.
60544 if (s_version >= 17)
5152 {
5153 // Reserved for z3.
5154 13312 }
5155
5156 // Enhanced music loop points
5157
2/2
✓ Branch 0 taken 13312 times.
✓ Branch 1 taken 47232 times.
60544 if (s_version >= 18)
5158 {
5159
2/4
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13312 times.
✗ Branch 3 not taken.
13312 if (!p_igetl(&tempDMap.tmusic_loop_start, f))
5160 {
5161 return qe_invalid;
5162 }
5163
2/4
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13312 times.
✗ Branch 3 not taken.
13312 if (!p_igetl(&tempDMap.tmusic_loop_end, f))
5164 {
5165 return qe_invalid;
5166 }
5167
2/4
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13312 times.
✗ Branch 3 not taken.
13312 if (!p_igetl(&tempDMap.tmusic_xfade_in, f))
5168 {
5169 return qe_invalid;
5170 }
5171
2/4
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13312 times.
✗ Branch 3 not taken.
13312 if (!p_igetl(&tempDMap.tmusic_xfade_out, f))
5172 {
5173 return qe_invalid;
5174 }
5175 13312 }
5176 else
5177 {
5178 47232 tempDMap.tmusic_loop_start = 0;
5179 47232 tempDMap.tmusic_loop_end = 0;
5180 47232 tempDMap.tmusic_xfade_in = 0;
5181 47232 tempDMap.tmusic_xfade_out = 0;
5182 }
5183
5184
2/2
✓ Branch 0 taken 13312 times.
✓ Branch 1 taken 47232 times.
60544 if(s_version >= 19)
5185
2/4
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13312 times.
✗ Branch 3 not taken.
13312 if(!p_getc(&tempDMap.overlay_subscreen, f))
5186 return qe_invalid;
5187
5188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60544 times.
60544 if (s_version >= 20)
5189 {
5190 if (!p_igetl(&tempDMap.intro_string_id, f))
5191 return qe_invalid;
5192 }
5193 else
5194 60544 tempDMap.intro_string_id = 0;
5195
5196 // Reserved for z3.
5197
1/2
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
60544 if(s_version >= 21)
5198 {
5199 for(int32_t j=0; j<8; j++)
5200 {
5201 for(int32_t k=0; k<8; k++)
5202 {
5203 char c;
5204 if(!p_getc(&c,f))
5205 {
5206 return qe_invalid;
5207 }
5208 }
5209 }
5210 }
5211
5212
1/2
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
60544 if (!should_skip)
5213 {
5214
1/2
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
60544 if(loading_tileset_flags & TILESET_CLEARMAPS)
5215 tempDMap.map = 0;
5216
1/2
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
60544 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
5217 {
5218 tempDMap.script = 0;
5219 for(int q = 0; q < 8; ++q)
5220 tempDMap.initD[q] = 0;
5221 }
5222
1/2
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
60544 DMaps[i] = tempDMap;
5223 60544 }
5224 60544 }
5225
5226 128 return 0;
5227 128 }
5228
5229 112 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5230 {
5231 //these are here to bypass compiler warnings about unused arguments
5232 112 Header=Header;
5233
5234 miscQdata temp_misc;
5235 112 word s_version=0, s_cversion=0;
5236 112 int32_t tempsize=0;
5237 word dummyw;
5238
5239 112 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5240
5241 //section version info
5242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(!p_igetw(&s_version,f))
5243 {
5244 return qe_invalid;
5245 }
5246
5247 112 FFCore.quest_format[vColours] = s_version;
5248
5249 112 al_trace("Misc Colours section version: %d\n", s_version);
5250
5251 //al_trace("Misc. colors version %d\n", s_version);
5252
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetw(&s_cversion,f))
5253 {
5254 return qe_invalid;
5255 }
5256
5257
5258 //section size
5259
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetl(&tempsize,f))
5260 {
5261 return qe_invalid;
5262 }
5263
5264 //finally... section data
5265 112 readsize=0;
5266
5267
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.text,f))
5268 {
5269 return qe_invalid;
5270 }
5271
5272
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.caption,f))
5273 {
5274 return qe_invalid;
5275 }
5276
5277
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.overw_bg,f))
5278 {
5279 return qe_invalid;
5280 }
5281
5282
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5283 {
5284 return qe_invalid;
5285 }
5286
5287
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5288 {
5289 return qe_invalid;
5290 }
5291
5292
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.cave_fg,f))
5293 {
5294 return qe_invalid;
5295 }
5296
5297
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.bs_dk,f))
5298 {
5299 return qe_invalid;
5300 }
5301
5302
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.bs_goal,f))
5303 {
5304 return qe_invalid;
5305 }
5306
5307
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.compass_lt,f))
5308 {
5309 return qe_invalid;
5310 }
5311
5312
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.compass_dk,f))
5313 {
5314 return qe_invalid;
5315 }
5316
5317
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5318 {
5319 return qe_invalid;
5320 }
5321
5322
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.triframe_color,f))
5323 {
5324 return qe_invalid;
5325 }
5326
5327
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.hero_dot,f))
5328 {
5329 return qe_invalid;
5330 }
5331
5332
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5333 {
5334 return qe_invalid;
5335 }
5336
5337
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5338 {
5339 return qe_invalid;
5340 }
5341
5342
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5343 {
5344 return qe_invalid;
5345 }
5346
5347
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5348 {
5349 return qe_invalid;
5350 }
5351
5352
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5353 {
5354 return qe_invalid;
5355 }
5356
5357
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5358 {
5359 return qe_invalid;
5360 }
5361
5362
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5363 {
5364 return qe_invalid;
5365 }
5366
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 77 times.
112 if(s_version < 4)
5367 {
5368
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5369 return qe_invalid;
5370 77 temp_misc.colors.triforce_tile = dummyw;
5371
5372
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5373 return qe_invalid;
5374 77 temp_misc.colors.triframe_tile = dummyw;
5375
5376
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5377 return qe_invalid;
5378 77 temp_misc.colors.overworld_map_tile = dummyw;
5379
5380
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5381 return qe_invalid;
5382 77 temp_misc.colors.dungeon_map_tile = dummyw;
5383
5384
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5385 return qe_invalid;
5386 77 temp_misc.colors.blueframe_tile = dummyw;
5387
5388
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5389 return qe_invalid;
5390 77 temp_misc.colors.HCpieces_tile = dummyw;
5391 77 }
5392
5393
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5394 {
5395 return qe_invalid;
5396 }
5397
5398
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5399 {
5400 return qe_invalid;
5401 }
5402
5403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(s_version < 2)
5404 {
5405 temp_misc.colors.msgtext = 0x01;
5406 }
5407 else
5408 {
5409
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.msgtext, f))
5410 {
5411 return qe_invalid;
5412 }
5413 }
5414
5415
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 35 times.
112 if ( s_version >= 3 ) //expanded tile pages to 825
5416 {
5417
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5418 {
5419 return qe_invalid;
5420 }
5421
5422
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5423 {
5424 return qe_invalid;
5425 }
5426
5427
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5428 {
5429 return qe_invalid;
5430 }
5431
5432
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5433 {
5434 return qe_invalid;
5435 }
5436
5437
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5438 {
5439 return qe_invalid;
5440 }
5441
5442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5443 {
5444 return qe_invalid;
5445 }
5446 35 }
5447
5448 112 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5449
5450 112 return 0;
5451 112 }
5452
5453 112 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5454 {
5455 miscQdata temp_misc;
5456 112 word s_version=0, s_cversion=0;
5457 byte icons;
5458 112 int32_t tempsize=0;
5459
5460 112 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5461
5462 //section version info
5463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(!p_igetw(&s_version,f))
5464 {
5465 return qe_invalid;
5466 }
5467
5468 112 FFCore.quest_format[vIcons] = s_version;
5469
5470 //al_trace("Game icons version %d\n", s_version);
5471
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetw(&s_cversion,f))
5472 {
5473 return qe_invalid;
5474 }
5475
5476
5477 //section size
5478
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetl(&tempsize,f))
5479 {
5480 return qe_invalid;
5481 }
5482
5483 //finally... section data
5484 112 readsize=0;
5485
5486 112 icons=4;
5487
5488
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 77 times.
112 if ( s_version >= 10 )
5489 {
5490
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t i=0; i<icons; i++)
5491 {
5492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_igetl(&temp_misc.icons[i],f))
5493 {
5494 return qe_invalid;
5495 }
5496 140 }
5497 35 }
5498 else
5499 {
5500
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<icons; i++)
5501 {
5502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 308 times.
308 if(!p_igetw(&temp_misc.icons[i],f))
5503 {
5504 return qe_invalid;
5505 }
5506 308 }
5507 }
5508
5509 112 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5510
5511 112 return 0;
5512 112 }
5513
5514 128 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5515 {
5516
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_misc);
5517
5518 128 word maxinfos=256;
5519 128 word maxshops=256;
5520 128 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5521 128 word ponds=16, pondsize=72, expansionsize=98*2;
5522 byte tempbyte, padding;
5523 miscQdata temp_misc;
5524 128 word s_version=0, s_cversion=0;
5525 word swaptmp;
5526 128 int32_t tempsize=0;
5527
5528 128 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5529
5530
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<maxshops; ++i)
5531 {
5532 32768 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5533 32768 }
5534
5535
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<maxinfos; ++i)
5536 {
5537 32768 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5538 32768 }
5539
5540
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(Header->zelda_version > 0x192)
5541 {
5542 //section version info
5543
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&s_version,f))
5544 {
5545 return qe_invalid;
5546 }
5547
5548 124 FFCore.quest_format[vMisc] = s_version;
5549
5550 //al_trace("Misc. data version %d\n", s_version);
5551
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&s_cversion,f))
5552 {
5553 return qe_invalid;
5554 }
5555
5556
5557 //section size
5558
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&tempsize,f))
5559 {
5560 return qe_invalid;
5561 }
5562 124 }
5563
5564 //finally... section data
5565 128 readsize=0;
5566
5567 //shops
5568
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(Header->zelda_version > 0x192)
5569 {
5570
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&shops,f))
5571 {
5572 return qe_invalid;
5573 }
5574 124 }
5575
5576
2/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
128 if (!(shops >= 0 && shops <= NUM_SHOPS))
5577 {
5578 return qe_invalid;
5579 }
5580
5581
2/2
✓ Branch 0 taken 1440 times.
✓ Branch 1 taken 128 times.
1568 for(int32_t i=0; i<shops; i++)
5582 {
5583
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 1217 times.
1440 if(s_version > 6)
5584 {
5585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1217 times.
1217 if(!pfread(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name),f))
5586 {
5587 return qe_invalid;
5588 }
5589 1217 }
5590
5591
2/2
✓ Branch 0 taken 4320 times.
✓ Branch 1 taken 1440 times.
5760 for(int32_t j=0; j<3; j++)
5592 {
5593
1/2
✓ Branch 0 taken 4320 times.
✗ Branch 1 not taken.
4320 if(!p_getc(&temp_misc.shop[i].item[j],f))
5594 {
5595 return qe_invalid;
5596 }
5597
5598
2/2
✓ Branch 0 taken 3651 times.
✓ Branch 1 taken 669 times.
4320 if(s_version < 4)
5599 {
5600 669 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5601 669 }
5602 4320 }
5603
5604
2/2
✓ Branch 0 taken 1376 times.
✓ Branch 1 taken 64 times.
1440 if(Header->zelda_version < 0x193)
5605 {
5606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(!p_getc(&tempbyte,f))
5607 {
5608 return qe_invalid;
5609 }
5610 64 }
5611
5612
2/2
✓ Branch 0 taken 4320 times.
✓ Branch 1 taken 1440 times.
5760 for(int32_t j=0; j<3; j++)
5613 {
5614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4320 times.
4320 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5615 {
5616 return qe_invalid;
5617 }
5618 4320 }
5619
5620
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 1217 times.
1440 if(s_version > 3)
5621 {
5622
2/2
✓ Branch 0 taken 3651 times.
✓ Branch 1 taken 1217 times.
4868 for(int32_t j=0; j<3; j++)
5623 {
5624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3651 times.
3651 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5625 return qe_invalid;
5626 3651 }
5627 1217 }
5628
5629 /*
5630 if(s_version < 8)
5631 {
5632 for(int32_t j=0; j<3; j++)
5633 {
5634 (&temp_misc.shop[i].str[j])=0; //initialise.
5635 }
5636 }
5637 */
5638 1440 }
5639
5640 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5641
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<maxshops; ++i)
5642 {
5643
2/2
✓ Branch 0 taken 65536 times.
✓ Branch 1 taken 32768 times.
98304 for(int32_t j=0; j<3-1; j++)
5644 {
5645
2/2
✓ Branch 0 taken 65536 times.
✓ Branch 1 taken 95331 times.
160867 for(int32_t k=0; k<2-j; k++)
5646 {
5647 95331 if(temp_misc.shop[i].hasitem[k]==0)
5648 {
5649 95331 swaptmp = temp_misc.shop[i].item[k];
5650 95331 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5651 95331 temp_misc.shop[i].item[k+1] = swaptmp;
5652 95331 swaptmp = temp_misc.shop[i].price[k];
5653 95331 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5654 95331 temp_misc.shop[i].price[k+1] = swaptmp;
5655 95331 swaptmp = temp_misc.shop[i].hasitem[k];
5656 95331 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5657 95331 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5658 95331 }
5659 95331 }
5660 65536 }
5661 32768 }
5662
5663 //infos
5664
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(Header->zelda_version > 0x192)
5665 {
5666
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&infos,f))
5667 {
5668 return qe_invalid;
5669 }
5670 124 }
5671
5672
2/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
128 if (!(infos >= 0 && infos <= NUM_INFOS))
5673 {
5674 return qe_invalid;
5675 }
5676
5677
5678
2/2
✓ Branch 0 taken 1751 times.
✓ Branch 1 taken 128 times.
1879 for(int32_t i=0; i<infos; i++)
5679 {
5680
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 1651 times.
1751 if(s_version > 6)
5681 {
5682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1651 times.
1651 if(!pfread(temp_misc.info[i].name,sizeof(temp_misc.info[i].name),f))
5683 {
5684 return qe_invalid;
5685 }
5686 1651 }
5687
5688
2/2
✓ Branch 0 taken 5253 times.
✓ Branch 1 taken 1751 times.
7004 for(int32_t j=0; j<3; j++)
5689 {
5690
2/4
✓ Branch 0 taken 5061 times.
✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5253 if((Header->zelda_version < 0x192)||
5691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5061 times.
5061 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5692 {
5693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5694 {
5695 return qe_invalid;
5696 }
5697
5698 192 temp_misc.info[i].str[j]=tempbyte;
5699 192 }
5700 else
5701 {
5702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5061 times.
5061 if(!p_igetw(&temp_misc.info[i].str[j],f))
5703 {
5704 return qe_invalid;
5705 }
5706 }
5707 5253 }
5708
5709
2/2
✓ Branch 0 taken 1687 times.
✓ Branch 1 taken 64 times.
1751 if(Header->zelda_version < 0x193)
5710 {
5711
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbyte,f))
5712 {
5713 return qe_invalid;
5714 }
5715 64 }
5716
5717
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1751 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1751 if((Header->zelda_version == 0x192)&&(Header->build>145))
5718 {
5719 if(!p_getc(&padding,f))
5720 {
5721 return qe_invalid;
5722 }
5723 }
5724
5725
2/2
✓ Branch 0 taken 5253 times.
✓ Branch 1 taken 1751 times.
7004 for(int32_t j=0; j<3; j++)
5726 {
5727
1/2
✓ Branch 0 taken 5253 times.
✗ Branch 1 not taken.
5253 if(!p_igetw(&temp_misc.info[i].price[j],f))
5728 {
5729 return qe_invalid;
5730 }
5731 5253 }
5732 1751 }
5733
5734 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5735
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<maxinfos; ++i)
5736 {
5737
2/2
✓ Branch 0 taken 65536 times.
✓ Branch 1 taken 32768 times.
98304 for(int32_t j=0; j<3-1; j++)
5738 {
5739
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 65536 times.
163840 for(int32_t k=0; k<2-j; k++)
5740 {
5741
2/2
✓ Branch 0 taken 2076 times.
✓ Branch 1 taken 96228 times.
98304 if(temp_misc.info[i].str[k]==0)
5742 {
5743 96228 swaptmp = temp_misc.info[i].str[k];
5744 96228 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5745 96228 temp_misc.info[i].str[k+1] = swaptmp;
5746 96228 swaptmp = temp_misc.info[i].price[k];
5747 96228 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5748 96228 temp_misc.info[i].price[k+1] = swaptmp;
5749 96228 }
5750 98304 }
5751 65536 }
5752 32768 }
5753
5754
5755 //warp rings
5756
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 112 times.
128 if(s_version > 5)
5757 112 warprings++;
5758
5759
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(Header->zelda_version > 0x192)
5760 {
5761
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&warprings,f))
5762 {
5763 return qe_invalid;
5764 }
5765
5766
3/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 86 times.
✓ Branch 3 taken 38 times.
124 if (!(warprings >= 0 && warprings <= NUM_WARP_RINGS))
5767 {
5768 // return qe_invalid;
5769 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5770 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5771 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5772 38 }
5773 124 }
5774
5775
2/2
✓ Branch 0 taken 1289 times.
✓ Branch 1 taken 128 times.
1417 for(int32_t i=0; i<warprings; i++)
5776 {
5777 // See above comment on the `warprings` range check.
5778 1289 bool keepdata = i < NUM_WARP_RINGS;
5779
5780
2/2
✓ Branch 0 taken 11377 times.
✓ Branch 1 taken 1289 times.
12666 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5781 {
5782
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 9585 times.
11377 if(s_version <= 3)
5783 {
5784
1/2
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
1792 if(!p_getc(&tempbyte,f))
5785 {
5786 return qe_invalid;
5787 }
5788
5789
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 1120 times.
1792 if (keepdata)
5790 1120 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5791 1792 }
5792 else
5793 {
5794 word tempword;
5795
1/2
✓ Branch 0 taken 9585 times.
✗ Branch 1 not taken.
9585 if(!p_igetw(&tempword,f))
5796 {
5797 return qe_invalid;
5798 }
5799
5800
2/2
✓ Branch 0 taken 513 times.
✓ Branch 1 taken 9072 times.
9585 if (keepdata)
5801 9072 temp_misc.warp[i].dmap[j] = tempword;
5802 }
5803 11377 }
5804
5805
2/2
✓ Branch 0 taken 11377 times.
✓ Branch 1 taken 1289 times.
12666 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5806 {
5807
1/2
✓ Branch 0 taken 11377 times.
✗ Branch 1 not taken.
11377 if(!p_getc(&tempbyte,f))
5808 {
5809 return qe_invalid;
5810 }
5811
2/2
✓ Branch 0 taken 1185 times.
✓ Branch 1 taken 10192 times.
11377 if (keepdata)
5812 10192 temp_misc.warp[i].scr[j] = tempbyte;
5813 11377 }
5814
5815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1289 times.
1289 if(!p_getc(&tempbyte,f))
5816 {
5817 return qe_invalid;
5818 }
5819
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1148 times.
1289 if (keepdata)
5820 1148 temp_misc.warp[i].size = tempbyte;
5821
5822
2/2
✓ Branch 0 taken 1257 times.
✓ Branch 1 taken 32 times.
1289 if(Header->zelda_version < 0x193)
5823 {
5824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!p_getc(&tempbyte,f))
5825 {
5826 return qe_invalid;
5827 }
5828 32 }
5829 1289 }
5830
5831 //palette cycles
5832
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5833 {
5834
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int32_t i=0; i<256; i++)
5835 {
5836
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 1024 times.
4096 for(int32_t j=0; j<3; j++)
5837 {
5838 3072 temp_misc.cycles[i][j].first=0;
5839 3072 temp_misc.cycles[i][j].count=0;
5840 3072 temp_misc.cycles[i][j].speed=0;
5841 3072 }
5842 1024 }
5843
5844
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
5845 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5846 {
5847 4 palcycles=16;
5848 4 }
5849
5850
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4 times.
68 for(int32_t i=0; i<palcycles; i++)
5851 {
5852
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 64 times.
256 for(int32_t j=0; j<3; j++)
5853 {
5854
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5855 {
5856 return qe_invalid;
5857 }
5858
5859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5860 {
5861 return qe_invalid;
5862 }
5863
5864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5865 {
5866 return qe_invalid;
5867 }
5868 192 }
5869 64 }
5870 4 }
5871
5872 //Wind warps are now just another warp ring.
5873
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version <= 5)
5874 {
5875
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
16 if(Header->zelda_version > 0x192)
5876 {
5877
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&windwarps,f))
5878 {
5879 return qe_invalid;
5880 }
5881 12 }
5882
5883
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
16 if (!(windwarps >= 0 && windwarps <= NUM_WARP_RINGS))
5884 {
5885 return qe_invalid;
5886 }
5887
5888
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 16 times.
151 for(int32_t i=0; i<windwarps; i++)
5889 {
5890
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(s_version <= 3)
5891 {
5892
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(!p_getc(&tempbyte,f))
5893 {
5894 return qe_invalid;
5895 }
5896
5897 135 temp_misc.warp[8].dmap[i]=tempbyte;
5898 135 }
5899 else
5900 {
5901 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5902 {
5903 return qe_invalid;
5904 }
5905 }
5906
5907
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5908 {
5909 return qe_invalid;
5910 }
5911
5912 135 temp_misc.warp[8].size = 9;
5913
5914
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(s_version == 5)
5915 {
5916 if(!p_getc(&tempbyte,f))
5917 {
5918 return qe_invalid;
5919 }
5920 }
5921 135 }
5922 16 }
5923
5924
5925 //triforce pieces
5926
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 128 times.
1152 for(int32_t i=0; i<triforces; i++)
5927 {
5928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 if(!p_getc(&temp_misc.triforce[i],f))
5929 {
5930 return qe_invalid;
5931 }
5932 1024 }
5933
5934 //misc color data
5935
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version<3)
5936 {
5937
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.text,f))
5938 {
5939 return qe_invalid;
5940 }
5941
5942
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.caption,f))
5943 {
5944 return qe_invalid;
5945 }
5946
5947
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.overw_bg,f))
5948 {
5949 return qe_invalid;
5950 }
5951
5952
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5953 {
5954 return qe_invalid;
5955 }
5956
5957
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5958 {
5959 return qe_invalid;
5960 }
5961
5962
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.cave_fg,f))
5963 {
5964 return qe_invalid;
5965 }
5966
5967
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bs_dk,f))
5968 {
5969 return qe_invalid;
5970 }
5971
5972
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bs_goal,f))
5973 {
5974 return qe_invalid;
5975 }
5976
5977
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.compass_lt,f))
5978 {
5979 return qe_invalid;
5980 }
5981
5982
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.compass_dk,f))
5983 {
5984 return qe_invalid;
5985 }
5986
5987
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5988 {
5989 return qe_invalid;
5990 }
5991
5992
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triframe_color,f))
5993 {
5994 return qe_invalid;
5995 }
5996
5997
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.hero_dot,f))
5998 {
5999 return qe_invalid;
6000 }
6001
6002
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bmap_bg,f))
6003 {
6004 return qe_invalid;
6005 }
6006
6007
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bmap_fg,f))
6008 {
6009 return qe_invalid;
6010 }
6011
6012
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triforce_cset,f))
6013 {
6014 return qe_invalid;
6015 }
6016
6017
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triframe_cset,f))
6018 {
6019 return qe_invalid;
6020 }
6021
6022
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
6023 {
6024 return qe_invalid;
6025 }
6026
6027
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
6028 {
6029 return qe_invalid;
6030 }
6031
6032
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
6033 {
6034 return qe_invalid;
6035 }
6036
6037
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
6038 {
6039 return qe_invalid;
6040 }
6041
6042
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
6043 {
6044 return qe_invalid;
6045 }
6046
6047
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
6048 {
6049 return qe_invalid;
6050 }
6051
6052
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
6053 {
6054 return qe_invalid;
6055 }
6056
6057
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
6058 {
6059 return qe_invalid;
6060 }
6061
6062
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
6063 {
6064 return qe_invalid;
6065 }
6066
6067
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
6068 {
6069 return qe_invalid;
6070 }
6071
6072 16 temp_misc.colors.msgtext = 0x01;
6073
6074
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 if(Header->zelda_version < 0x193)
6075 {
6076
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 4 times.
32 for(int32_t i=0; i<7; i++)
6077 {
6078
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_getc(&tempbyte,f))
6079 {
6080 return qe_invalid;
6081 }
6082 28 }
6083 4 }
6084
6085
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if((Header->zelda_version == 0x192)&&(Header->build>145))
6086 {
6087 for(int32_t i=0; i<256; i++)
6088 {
6089 if(!p_getc(&tempbyte,f))
6090 {
6091 return qe_invalid;
6092 }
6093 }
6094 }
6095
6096
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(s_version>1)
6097 {
6098 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
6099 {
6100 return qe_invalid;
6101 }
6102 }
6103
6104 //save game icons
6105
2/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if((Header->zelda_version < 0x192)||
6106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6107 {
6108 4 icons=3;
6109 4 }
6110
6111
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 16 times.
76 for(int32_t i=0; i<icons; i++)
6112 {
6113
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_igetw(&temp_misc.icons[i],f))
6114 {
6115 return qe_invalid;
6116 }
6117 60 }
6118 16 }
6119
6120
2/4
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
128 if((Header->zelda_version < 0x192)||
6121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6122 {
6123 4 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6124
6125 4 return 0;
6126 }
6127
6128 //pond information
6129
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(Header->zelda_version < 0x193)
6130 {
6131 if((Header->zelda_version == 0x192)&&(Header->build<146))
6132 {
6133 pondsize=25;
6134 }
6135
6136 for(int32_t i=0; i<ponds; i++)
6137 {
6138 for(int32_t j=0; j<pondsize; j++)
6139 {
6140 if(!p_getc(&tempbyte,f))
6141 {
6142 return qe_invalid;
6143
6144 }
6145 }
6146 }
6147 }
6148
6149 //end string
6150
1/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
124 if((Header->zelda_version < 0x192)||
6151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6152 {
6153 if(!p_getc(&tempbyte,f))
6154 {
6155 return qe_invalid;
6156 }
6157
6158 temp_misc.endstring=tempbyte;
6159
6160 if(!p_getc(&tempbyte,f))
6161 {
6162 return qe_invalid;
6163 }
6164 }
6165 else
6166 {
6167
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&temp_misc.endstring,f))
6168 {
6169 return qe_invalid;
6170 }
6171 }
6172
6173 //expansion
6174
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(Header->zelda_version < 0x193)
6175 {
6176 if((Header->zelda_version == 0x192)&&(Header->build<73))
6177 {
6178 expansionsize=99*2;
6179 }
6180
6181 for(int32_t i=0; i<expansionsize; i++)
6182 {
6183 if(!p_getc(&tempbyte,f))
6184 {
6185 return qe_invalid;
6186 }
6187 }
6188 }
6189 //shops v8
6190
6191
6192
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 35 times.
124 if(s_version >= 8)
6193 {
6194
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 35 times.
547 for(int32_t i=0; i<shops; i++)
6195 {
6196
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 512 times.
2048 for(int32_t j=0; j<3; j++)
6197 {
6198
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetw(&temp_misc.shop[i].str[j],f))
6199 return qe_invalid;
6200 1536 }
6201 512 }
6202 35 }
6203
6204 124 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6205 124 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6206 124 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6207
6208 //v9 includes quest misc[32]
6209
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 35 times.
124 if(s_version >= 9)
6210 {
6211
2/2
✓ Branch 0 taken 1120 times.
✓ Branch 1 taken 35 times.
1155 for ( int32_t q = 0; q < 32; q++ )
6212 {
6213
1/2
✓ Branch 0 taken 1120 times.
✗ Branch 1 not taken.
1120 if(!p_igetl(&temp_misc.questmisc[q],f))
6214 return qe_invalid;
6215 1120 }
6216
2/2
✓ Branch 0 taken 1120 times.
✓ Branch 1 taken 35 times.
1155 for ( int32_t q = 0; q < 32; q++ )
6217 {
6218
2/2
✓ Branch 0 taken 143360 times.
✓ Branch 1 taken 1120 times.
144480 for ( int32_t j = 0; j < 128; j++ )
6219
1/2
✓ Branch 0 taken 143360 times.
✗ Branch 1 not taken.
143360 if(!p_getc(&temp_misc.questmisc_strings[q][j],f))
6220 return qe_invalid;
6221 1120 }
6222 35 }
6223
6224
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 89 times.
124 if(s_version >= 11 )
6225 {
6226
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6227 return qe_invalid;
6228 35 }
6229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(s_version < 11 )
6230 {
6231 89 temp_misc.zscript_last_compiled_version = -1;
6232 89 }
6233
6234 124 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6235
6236
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 89 times.
124 if(s_version >= 12)
6237 {
6238 byte spr;
6239
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 35 times.
8995 for(int32_t q = 0; q < sprMAX; ++q)
6240 {
6241
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_getc(&spr,f))
6242 return qe_invalid;
6243 8960 temp_misc.sprites[q] = spr;
6244 8960 }
6245 35 }
6246 else
6247 {
6248 89 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6249 //temp_misc.sprites[sprFALL] = ;
6250 }
6251
6252
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 89 times.
124 if(s_version >= 13)
6253 {
6254
2/2
✓ Branch 0 taken 2240 times.
✓ Branch 1 taken 35 times.
2275 for(size_t q = 0; q < 64; ++q)
6255 {
6256 2240 bottletype* bt = &(temp_misc.bottle_types[q]);
6257
1/2
✓ Branch 0 taken 2240 times.
✗ Branch 1 not taken.
2240 if (!pfread(bt->name, 32, f))
6258 return qe_invalid;
6259
2/2
✓ Branch 0 taken 6720 times.
✓ Branch 1 taken 2240 times.
8960 for(size_t j = 0; j < 3; ++j)
6260 {
6261
1/2
✓ Branch 0 taken 6720 times.
✗ Branch 1 not taken.
6720 if (!p_getc(&(bt->counter[j]), f))
6262 return qe_invalid;
6263
1/2
✓ Branch 0 taken 6720 times.
✗ Branch 1 not taken.
6720 if (!p_igetw(&(bt->amount[j]), f))
6264 return qe_invalid;
6265 6720 }
6266
1/2
✓ Branch 0 taken 2240 times.
✗ Branch 1 not taken.
2240 if (!p_getc(&(bt->flags), f))
6267 return qe_invalid;
6268
1/2
✓ Branch 0 taken 2240 times.
✗ Branch 1 not taken.
2240 if (!p_getc(&(bt->next_type), f))
6269 return qe_invalid;
6270 2240 }
6271
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 35 times.
8995 for(size_t q = 0; q < 256; ++q)
6272 {
6273 8960 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6274
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if (!pfread(bst->name, 32, f))
6275 return qe_invalid;
6276
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 8960 times.
35840 for(size_t j = 0; j < 3; ++j)
6277 {
6278
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if (!p_getc(&(bst->fill[j]), f))
6279 return qe_invalid;
6280
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if (!p_igetw(&(bst->comb[j]), f))
6281 return qe_invalid;
6282
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if (!p_getc(&(bst->cset[j]), f))
6283 return qe_invalid;
6284
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if (!p_igetw(&(bst->price[j]), f))
6285 return qe_invalid;
6286
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if (!p_igetw(&(bst->str[j]), f))
6287 return qe_invalid;
6288 26880 }
6289 8960 }
6290 35 }
6291 else
6292 {
6293
2/2
✓ Branch 0 taken 5696 times.
✓ Branch 1 taken 89 times.
5785 for(size_t q = 0; q < 64; ++q)
6294 5696 temp_misc.bottle_types[q].clear();
6295
2/2
✓ Branch 0 taken 22784 times.
✓ Branch 1 taken 89 times.
22873 for(size_t q = 0; q < 256; ++q)
6296 22784 temp_misc.bottle_shop_types[q].clear();
6297 }
6298
6299
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 89 times.
124 if(s_version >= 14)
6300 {
6301 byte msfx;
6302
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 35 times.
8995 for(int32_t q = 0; q < sfxMAX; ++q)
6303 {
6304
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_getc(&msfx,f))
6305 return qe_invalid;
6306 8960 temp_misc.miscsfx[q] = msfx;
6307 8960 }
6308 35 }
6309 else
6310 {
6311 89 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6312 89 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6313 89 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6314 }
6315
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 89 times.
124 if(s_version < 15)
6316 {
6317 89 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6318 89 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6319 89 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6320 89 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6321 89 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6322 89 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6323 89 }
6324
6325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if (!should_skip)
6326 124 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6327
6328 124 return 0;
6329 128 }
6330
6331 extern char *item_string[MAXITEMS];
6332 extern const char *old_item_string[iLast];
6333 extern char *weapon_string[MAXWPNS];
6334 extern const char *old_weapon_string[wLast];
6335
6336 128 int32_t readitems(PACKFILE *f, word version, word build)
6337 {
6338
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_items);
6339
6340 byte padding;
6341 int32_t dummy;
6342 128 word items_to_read=MAXITEMS;
6343 itemdata tempitem;
6344 128 word s_version=0, s_cversion=0;
6345 word dummy_word;
6346
6347
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(version < 0x186)
6348 {
6349 items_to_read=64;
6350 }
6351
6352
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(version > 0x192)
6353 {
6354 124 items_to_read=0;
6355
6356 //section version info
6357
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&s_version,f))
6358 {
6359 return qe_invalid;
6360 }
6361
6362 124 FFCore.quest_format[vItems] = s_version;
6363
6364 //al_trace("Items version %d\n", s_version);
6365
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&s_cversion,f))
6366 {
6367 return qe_invalid;
6368 }
6369
6370 //section size
6371
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&dummy,f))
6372 {
6373 return qe_invalid;
6374 }
6375
6376 //finally... section data
6377
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&items_to_read,f))
6378 {
6379 return qe_invalid;
6380 }
6381
6382
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
124 if (!(items_to_read >= 0 && items_to_read <= MAXITEMS))
6383 {
6384 return qe_invalid;
6385 }
6386 124 }
6387
6388
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version>1)
6389 {
6390
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 112 times.
28784 for(int32_t i=0; i<items_to_read; i++)
6391 {
6392 char tempname[64];
6393
6394
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!pfread(tempname, 64, f))
6395 {
6396 return qe_invalid;
6397 }
6398
6399 28672 item_string[i][0] = '\0';
6400 28672 strncat(item_string[i], tempname, 64 - 1);
6401 28672 }
6402 112 }
6403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 else if (!should_skip)
6404 {
6405
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t i=0; i<MAXITEMS; i++)
6406 {
6407 4096 reset_itemname(i);
6408 4096 }
6409 16 }
6410
6411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (!should_skip)
6412
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<MAXITEMS; i++)
6413 {
6414 32768 itemdata& id = itemsbuf[i];
6415 32768 memset(&id, 0, sizeof(itemdata));
6416 32768 id.count=-1;
6417 32768 id.playsound=WAV_SCALE;
6418 32768 reset_itembuf(&id,i);
6419 32896 }
6420
6421
2/2
✓ Branch 0 taken 30536 times.
✓ Branch 1 taken 128 times.
30664 for(int32_t i=0; i<items_to_read; i++)
6422 {
6423 30536 memset(&tempitem, 0, sizeof(itemdata));
6424 30536 reset_itembuf(&tempitem,i);
6425
6426
6427
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 21576 times.
30536 if ( s_version > 35 ) //expanded tiles
6428 {
6429
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.tile,f))
6430 {
6431 return qe_invalid;
6432 }
6433 8960 }
6434 else
6435 {
6436
1/2
✓ Branch 0 taken 21576 times.
✗ Branch 1 not taken.
21576 if(!p_igetw(&tempitem.tile,f))
6437 {
6438 return qe_invalid;
6439 }
6440 }
6441
6442
1/2
✓ Branch 0 taken 30536 times.
✗ Branch 1 not taken.
30536 if(!p_getc(&tempitem.misc_flags,f))
6443 {
6444 return qe_invalid;
6445 }
6446
6447
1/2
✓ Branch 0 taken 30536 times.
✗ Branch 1 not taken.
30536 if(!p_getc(&tempitem.csets,f))
6448 {
6449 return qe_invalid;
6450 }
6451
6452
1/2
✓ Branch 0 taken 30536 times.
✗ Branch 1 not taken.
30536 if(!p_getc(&tempitem.frames,f))
6453 {
6454 return qe_invalid;
6455 }
6456
6457
1/2
✓ Branch 0 taken 30536 times.
✗ Branch 1 not taken.
30536 if(!p_getc(&tempitem.speed,f))
6458 {
6459 return qe_invalid;
6460 }
6461
6462
1/2
✓ Branch 0 taken 30536 times.
✗ Branch 1 not taken.
30536 if(!p_getc(&tempitem.delay,f))
6463 {
6464 return qe_invalid;
6465 }
6466
6467
2/2
✓ Branch 0 taken 29512 times.
✓ Branch 1 taken 1024 times.
30536 if(version < 0x193)
6468 {
6469
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f))
6470 {
6471 return qe_invalid;
6472 }
6473
6474
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1024 if((version < 0x192)||((version == 0x192)&&(build<186)))
6475 {
6476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 if (should_skip)
6477 continue;
6478
6479
3/3
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
1024 switch(i)
6480 {
6481 case iShield:
6482 4 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6483 4 break;
6484
6485 case iMShield:
6486 4 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6487 4 break;
6488
6489 default:
6490 1016 tempitem.ltm=0;
6491 1016 break;
6492 }
6493
6494 1024 tempitem.count=-1;
6495 1024 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6496 1024 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6497 1024 tempitem.family=0xFF;
6498 1024 tempitem.playsound=WAV_SCALE;
6499 1024 reset_itembuf(&tempitem,i);
6500
6501 1024 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6502
6503 1024 continue;
6504 }
6505 }
6506
6507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29512 times.
29512 if(!p_igetl(&tempitem.ltm,f))
6508 {
6509 return qe_invalid;
6510 }
6511
6512
1/2
✓ Branch 0 taken 29512 times.
✗ Branch 1 not taken.
29512 if(version < 0x193)
6513 {
6514 for(int32_t q=0; q<12; q++)
6515 {
6516 if(!p_getc(&padding,f))
6517 {
6518 return qe_invalid;
6519 }
6520 }
6521 }
6522
6523
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 840 times.
29512 if(s_version>1)
6524 {
6525
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 19712 times.
28672 if ( s_version >= 31 )
6526 {
6527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetl(&tempitem.family,f))
6528 {
6529 return qe_invalid;
6530 }
6531 8960 }
6532 else
6533 {
6534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19712 times.
19712 if(!p_getc(&tempitem.family,f))
6535 {
6536 return qe_invalid;
6537 }
6538 }
6539
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(s_version < 16)
6540 if(tempitem.family == 0xFF)
6541 tempitem.family = itype_misc;
6542
6543
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_getc(&tempitem.fam_type,f))
6544 {
6545 return qe_invalid;
6546 }
6547
6548
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(s_version>5)
6549 {
6550
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 19712 times.
28672 if(s_version>=31)
6551 {
6552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetl(&tempitem.power,f))
6553 {
6554 return qe_invalid;
6555 }
6556 8960 }
6557 else
6558 {
6559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19712 times.
19712 if(!p_getc(&tempitem.power,f))
6560 {
6561 return qe_invalid;
6562 }
6563 }
6564
6565 //converted flags from 16b to 32b -Z
6566
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
28672 if ( s_version < 41 )
6567 {
6568
1/2
✓ Branch 0 taken 19712 times.
✗ Branch 1 not taken.
19712 if(!p_igetw(&tempitem.flags,f))
6569 {
6570 return qe_invalid;
6571 }
6572 19712 }
6573 else
6574 {
6575
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.flags,f))
6576 {
6577 return qe_invalid;
6578 }
6579 }
6580 28672 }
6581 else
6582 {
6583 //tempitem.power = tempitem.fam_type;
6584 char tempchar;
6585
6586 if(!p_getc(&tempchar,f))
6587 {
6588 return qe_invalid;
6589 }
6590
6591 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6592 }
6593
6594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(!p_igetw(&tempitem.script,f))
6595 {
6596 return qe_invalid;
6597 }
6598
6599
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(s_version<=3)
6600 {
6601 if(tempitem.script > NUMSCRIPTITEM)
6602 {
6603 tempitem.script = 0;
6604 }
6605 }
6606
6607
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_getc(&tempitem.count,f))
6608 {
6609 return qe_invalid;
6610 }
6611
6612
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_igetw(&tempitem.amount,f))
6613 {
6614 return qe_invalid;
6615 }
6616
6617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(!p_igetw(&tempitem.collect_script,f))
6618 {
6619 return qe_invalid;
6620 }
6621
6622
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(s_version<=3)
6623 {
6624 if(tempitem.collect_script > NUMSCRIPTITEM)
6625 {
6626 tempitem.collect_script = 0;
6627 }
6628 }
6629
6630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(!p_igetw(&tempitem.setmax,f))
6631 {
6632 return qe_invalid;
6633 }
6634
6635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(!p_igetw(&tempitem.max,f))
6636 {
6637 return qe_invalid;
6638 }
6639
6640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(!p_getc(&tempitem.playsound,f))
6641 {
6642 return qe_invalid;
6643 }
6644
6645
2/2
✓ Branch 0 taken 229376 times.
✓ Branch 1 taken 28672 times.
258048 for(int32_t j=0; j<8; j++)
6646 {
6647
1/2
✓ Branch 0 taken 229376 times.
✗ Branch 1 not taken.
229376 if(!p_igetl(&tempitem.initiald[j],f))
6648 {
6649 return qe_invalid;
6650 }
6651 229376 }
6652
6653
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 28672 times.
86016 for(int32_t j=0; j<2; j++)
6654 {
6655
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_getc(&tempitem.initiala[j],f))
6656 {
6657 return qe_invalid;
6658 }
6659 57344 }
6660
6661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(s_version>4)
6662 {
6663
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(s_version>5)
6664 {
6665
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_getc(&tempitem.wpn,f))
6666 {
6667 return qe_invalid;
6668 }
6669
6670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(!p_getc(&tempitem.wpn2,f))
6671 {
6672 return qe_invalid;
6673 }
6674
6675
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_getc(&tempitem.wpn3,f))
6676 {
6677 return qe_invalid;
6678 }
6679
6680
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_getc(&tempitem.wpn4,f))
6681 {
6682 return qe_invalid;
6683 }
6684
6685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(s_version>=15)
6686 {
6687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(!p_getc(&tempitem.wpn5,f))
6688 {
6689 return qe_invalid;
6690 }
6691
6692
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_getc(&tempitem.wpn6,f))
6693 {
6694 return qe_invalid;
6695 }
6696
6697
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_getc(&tempitem.wpn7,f))
6698 {
6699 return qe_invalid;
6700 }
6701
6702
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_getc(&tempitem.wpn8,f))
6703 {
6704 return qe_invalid;
6705 }
6706
6707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(!p_getc(&tempitem.wpn9,f))
6708 {
6709 return qe_invalid;
6710 }
6711
6712
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_getc(&tempitem.wpn10,f))
6713 {
6714 return qe_invalid;
6715 }
6716 28672 }
6717
6718
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_getc(&tempitem.pickup_hearts,f))
6719 {
6720 return qe_invalid;
6721 }
6722
6723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(s_version<15)
6724 {
6725 if(!p_igetw(&dummy_word,f))
6726 {
6727 return qe_invalid;
6728 }
6729
6730 tempitem.misc1=dummy_word;
6731
6732 if(!p_igetw(&dummy_word,f))
6733 {
6734 return qe_invalid;
6735 }
6736
6737 tempitem.misc2=dummy_word;
6738 }
6739 else
6740 {
6741
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_igetl(&tempitem.misc1,f))
6742 {
6743 return qe_invalid;
6744 }
6745
6746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(!p_igetl(&tempitem.misc2,f))
6747 {
6748 return qe_invalid;
6749 }
6750
6751 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6752
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(s_version<24)
6753 {
6754 if(tempitem.family==itype_shield)
6755 {
6756 tempitem.misc1|=shSCRIPT;
6757 }
6758 }
6759 }
6760
6761
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
28672 if(s_version < 53)
6762 {
6763 byte tempbyte;
6764
1/2
✓ Branch 0 taken 19712 times.
✗ Branch 1 not taken.
19712 if(!p_getc(&tempbyte,f))
6765 {
6766 return qe_invalid;
6767 }
6768 19712 tempitem.cost_amount[0] = tempbyte;
6769 19712 }
6770 else
6771 {
6772
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 8960 times.
26880 for(auto q = 0; q < 2; ++q)
6773 {
6774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17920 times.
17920 if(!p_igetw(&tempitem.cost_amount[q],f))
6775 {
6776 return qe_invalid;
6777 }
6778 17920 }
6779 }
6780 28672 }
6781 else
6782 {
6783 char tempchar;
6784
6785 if(!p_getc(&tempchar,f))
6786 {
6787 return qe_invalid;
6788 }
6789
6790 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6791 }
6792
6793 // June 2007: more misc. attributes
6794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(s_version>=12)
6795 {
6796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(s_version<15)
6797 {
6798 if(!p_igetw(&dummy_word,f))
6799 {
6800 return qe_invalid;
6801 }
6802
6803 tempitem.misc3=dummy_word;
6804
6805 if(!p_igetw(&dummy_word,f))
6806 {
6807 return qe_invalid;
6808 }
6809
6810 tempitem.misc4=dummy_word;
6811 }
6812 else
6813 {
6814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(!p_igetl(&tempitem.misc3,f))
6815 {
6816 return qe_invalid;
6817 }
6818
6819
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_igetl(&tempitem.misc4,f))
6820 {
6821 return qe_invalid;
6822 }
6823
6824
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_igetl(&tempitem.misc5,f))
6825 {
6826 return qe_invalid;
6827 }
6828
6829
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_igetl(&tempitem.misc6,f))
6830 {
6831 return qe_invalid;
6832 }
6833
6834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(!p_igetl(&tempitem.misc7,f))
6835 {
6836 return qe_invalid;
6837 }
6838
6839
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_igetl(&tempitem.misc8,f))
6840 {
6841 return qe_invalid;
6842 }
6843
6844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(!p_igetl(&tempitem.misc9,f))
6845 {
6846 return qe_invalid;
6847 }
6848
6849
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_igetl(&tempitem.misc10,f))
6850 {
6851 return qe_invalid;
6852 }
6853 }
6854
6855
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_getc(&tempitem.usesound,f))
6856 {
6857 return qe_invalid;
6858 }
6859
6860
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 19712 times.
28672 if(s_version >= 49)
6861 {
6862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_getc(&tempitem.usesound2,f))
6863 {
6864 return qe_invalid;
6865 }
6866 8960 }
6867 19712 else tempitem.usesound2 = 0;
6868
6869
3/4
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
✓ Branch 2 taken 19712 times.
✗ Branch 3 not taken.
28672 if(s_version < 50 && tempitem.family == itype_mirror)
6870 {
6871 //Split continue/dmap warp effect/sfx, port for old
6872 tempitem.misc2 = tempitem.misc1;
6873 tempitem.usesound2 = tempitem.usesound;
6874 }
6875 28672 }
6876 28672 }
6877
6878
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
28672 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6879 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_getc(&tempitem.useweapon,f))
6881 {
6882 return qe_invalid;
6883 }
6884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_getc(&tempitem.usedefence,f))
6885 {
6886 return qe_invalid;
6887 }
6888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetl(&tempitem.weaprange,f))
6889 {
6890 return qe_invalid;
6891 }
6892
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.weapduration,f))
6893 {
6894 return qe_invalid;
6895 }
6896
2/2
✓ Branch 0 taken 89600 times.
✓ Branch 1 taken 8960 times.
98560 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6897 {
6898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89600 times.
89600 if(!p_igetl(&tempitem.weap_pattern[q],f))
6899 {
6900 return qe_invalid;
6901 }
6902 89600 }
6903 8960 }
6904
6905
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
28672 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6906 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6907
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.duplicates,f))
6908 {
6909 return qe_invalid;
6910 }
6911
2/2
✓ Branch 0 taken 71680 times.
✓ Branch 1 taken 8960 times.
80640 for ( int32_t q = 0; q < INITIAL_D; q++ )
6912 {
6913
1/2
✓ Branch 0 taken 71680 times.
✗ Branch 1 not taken.
71680 if(!p_igetl(&tempitem.weap_initiald[q],f))
6914 {
6915 return qe_invalid;
6916 }
6917 71680 }
6918
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 8960 times.
26880 for ( int32_t q = 0; q < INITIAL_A; q++ )
6919 {
6920
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_getc(&tempitem.weap_initiala[q],f))
6921 {
6922 return qe_invalid;
6923 }
6924 17920 }
6925
6926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_getc(&tempitem.drawlayer,f))
6927 {
6928 return qe_invalid;
6929 }
6930
6931
6932
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.hxofs,f))
6933 {
6934 return qe_invalid;
6935 }
6936
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.hyofs,f))
6937 {
6938 return qe_invalid;
6939 }
6940
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.hxsz,f))
6941 {
6942 return qe_invalid;
6943 }
6944
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.hysz,f))
6945 {
6946 return qe_invalid;
6947 }
6948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetl(&tempitem.hzsz,f))
6949 {
6950 return qe_invalid;
6951 }
6952
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.xofs,f))
6953 {
6954 return qe_invalid;
6955 }
6956
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.yofs,f))
6957 {
6958 return qe_invalid;
6959 }
6960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetl(&tempitem.weap_hxofs,f))
6961 {
6962 return qe_invalid;
6963 }
6964
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.weap_hyofs,f))
6965 {
6966 return qe_invalid;
6967 }
6968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetl(&tempitem.weap_hxsz,f))
6969 {
6970 return qe_invalid;
6971 }
6972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetl(&tempitem.weap_hysz,f))
6973 {
6974 return qe_invalid;
6975 }
6976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetl(&tempitem.weap_hzsz,f))
6977 {
6978 return qe_invalid;
6979 }
6980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetl(&tempitem.weap_xofs,f))
6981 {
6982 return qe_invalid;
6983 }
6984
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.weap_yofs,f))
6985 {
6986 return qe_invalid;
6987 }
6988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetw(&tempitem.weaponscript,f))
6989 {
6990 return qe_invalid;
6991 }
6992
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.wpnsprite,f))
6993 {
6994 return qe_invalid;
6995 }
6996 8960 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6997
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 8960 times.
26880 for(auto q = 0; q < num_cost_tmr; ++q)
6998 {
6999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17920 times.
17920 if(!p_igetl(&tempitem.magiccosttimer[q],f))
7000 {
7001 return qe_invalid;
7002 }
7003 17920 }
7004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 for(auto q = num_cost_tmr; q < 2; ++q)
7005 tempitem.magiccosttimer[q] = 0;
7006 8960 }
7007
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
28672 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
7008 {
7009 //Item Size FLags, TileWidth, TileHeight
7010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetl(&tempitem.overrideFLAGS,f))
7011 {
7012 return qe_invalid;
7013 }
7014
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.tilew,f))
7015 {
7016 return qe_invalid;
7017 }
7018
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.tileh,f))
7019 {
7020 return qe_invalid;
7021 }
7022 8960 }
7023
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
28672 if ( s_version >= 29 ) //! More new vars.
7024 {
7025 //Item Size FLags, TileWidth, TileHeight
7026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetl(&tempitem.weapoverrideFLAGS,f))
7027 {
7028 return qe_invalid;
7029 }
7030
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.weap_tilew,f))
7031 {
7032 return qe_invalid;
7033 }
7034
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.weap_tileh,f))
7035 {
7036 return qe_invalid;
7037 }
7038 8960 }
7039
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
28672 if ( s_version >= 30 ) //! More new vars.
7040 {
7041 //Pickup Type
7042
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.pickup,f))
7043 {
7044 return qe_invalid;
7045 }
7046 8960 }
7047
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
28672 if ( s_version >= 32 ) //! More new vars.
7048 {
7049 //Pickup Type
7050
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetw(&tempitem.pstring,f))
7051 {
7052 return qe_invalid;
7053 }
7054 8960 }
7055
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
28672 if ( s_version >= 33 ) //! More new vars.
7056 {
7057 //Pickup Type
7058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetw(&tempitem.pickup_string_flags,f))
7059 {
7060 return qe_invalid;
7061 }
7062 8960 }
7063
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
28672 if ( s_version >= 34 ) //! cost counter
7064 {
7065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(s_version < 53)
7066 {
7067 if(!p_getc(&tempitem.cost_counter[0],f))
7068 {
7069 return qe_invalid;
7070 }
7071 }
7072 else
7073 {
7074
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 8960 times.
26880 for(auto q = 0; q < 2; ++q)
7075 {
7076
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_getc(&tempitem.cost_counter[q],f))
7077 {
7078 return qe_invalid;
7079 }
7080 17920 }
7081 }
7082 8960 }
7083
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
28672 if ( s_version >= 44 ) //! sprite scripts
7084 {
7085
2/2
✓ Branch 0 taken 71680 times.
✓ Branch 1 taken 8960 times.
80640 for ( int32_t q = 0; q < 8; q++ )
7086 {
7087
2/2
✓ Branch 0 taken 4659200 times.
✓ Branch 1 taken 71680 times.
4730880 for ( int32_t w = 0; w < 65; w++ )
7088 {
7089
1/2
✓ Branch 0 taken 4659200 times.
✗ Branch 1 not taken.
4659200 if(!p_getc(&(tempitem.initD_label[q][w]),f))
7090 {
7091 return qe_invalid;
7092 }
7093 4659200 }
7094
2/2
✓ Branch 0 taken 4659200 times.
✓ Branch 1 taken 71680 times.
4730880 for ( int32_t w = 0; w < 65; w++ )
7095 {
7096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4659200 times.
4659200 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f))
7097 {
7098 return qe_invalid;
7099 }
7100 4659200 }
7101
2/2
✓ Branch 0 taken 4659200 times.
✓ Branch 1 taken 71680 times.
4730880 for ( int32_t w = 0; w < 65; w++ )
7102 {
7103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4659200 times.
4659200 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
7104 {
7105 return qe_invalid;
7106 }
7107 4659200 }
7108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71680 times.
71680 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
7109 {
7110 return qe_invalid;
7111 }
7112
7113 71680 }
7114
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 8960 times.
26880 for ( int32_t q = 0; q < 2; q++ )
7115 {
7116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17920 times.
17920 if(!p_getc(&(tempitem.sprite_initiala[q]),f))
7117 {
7118 return qe_invalid;
7119 }
7120 17920 }
7121 //Pickup Type
7122
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetw(&tempitem.sprite_script,f))
7123 {
7124 return qe_invalid;
7125 }
7126 8960 }
7127
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
28672 if ( s_version >= 48 ) //! pickup flags
7128 {
7129
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_getc(&(tempitem.pickupflag),f))
7130 {
7131 return qe_invalid;
7132 }
7133 8960 }
7134
2/2
✓ Branch 0 taken 21248 times.
✓ Branch 1 taken 7424 times.
28672 if ( s_version >= 57 )
7135 {
7136 7424 std::string str;
7137
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
✓ Branch 2 taken 7424 times.
✗ Branch 3 not taken.
7424 if(!p_getcstr(&str,f))
7138 return qe_invalid;
7139 7424 strncpy(tempitem.display_name,str.c_str(),255);
7140
1/3
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
7424 }
7141 28672 }
7142 else
7143 {
7144 840 tempitem.count=-1;
7145 840 tempitem.family=itype_misc;
7146 840 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7147 840 tempitem.playsound=WAV_SCALE;
7148 840 reset_itembuf(&tempitem,i);
7149 }
7150
7151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29512 times.
29512 if (!should_skip)
7152 {
7153
1/2
✓ Branch 0 taken 29512 times.
✗ Branch 1 not taken.
29512 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
7154 {
7155 tempitem.script = 0;
7156 tempitem.weaponscript = 0;
7157 for(int q = 0; q < 8; ++q)
7158 {
7159 tempitem.initiald[q] = 0;
7160 tempitem.weap_initiald[q] = 0;
7161 }
7162 }
7163 29512 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7164 29512 }
7165 29512 }
7166
7167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (should_skip)
7168 return 0;
7169
7170 //////////////////////////////////////////////////////
7171 // Now do any updates because of new item additions
7172 // (These can't be done above because items_to_read
7173 // might be too low.)
7174 //////////////////////////////////////////////////////
7175
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<MAXITEMS; i++)
7176 {
7177 32768 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7178
7179 //Account for older quests that didn't have an actual item for the used letter
7180
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 28672 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
32768 if(s_version < 2 && i==iLetterUsed)
7181 {
7182 16 reset_itembuf(&tempitem, iLetterUsed);
7183 16 strcpy(item_string[i],old_item_string[i]);
7184 16 tempitem.tile = itemsbuf[iLetter].tile;
7185 16 tempitem.csets = itemsbuf[iLetter].csets;
7186 16 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7187 16 tempitem.frames = itemsbuf[iLetter].frames;
7188 16 tempitem.speed = itemsbuf[iLetter].speed;
7189 16 tempitem.ltm = itemsbuf[iLetter].ltm;
7190 16 }
7191
7192
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 3)
7193 {
7194
3/3
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 3728 times.
✓ Branch 2 taken 16 times.
4096 switch(i)
7195 {
7196 case iRocsFeather:
7197 case iHoverBoots:
7198 case iSpinScroll:
7199 case iL2SpinScroll:
7200 case iCrossScroll:
7201 case iQuakeScroll:
7202 case iL2QuakeScroll:
7203 case iWhispRing:
7204 case iL2WhispRing:
7205 case iChargeRing:
7206 case iL2ChargeRing:
7207 case iPerilScroll:
7208 case iWalletL3:
7209 case iQuiverL4:
7210 case iBombBagL4:
7211 case iBracelet:
7212 case iL2Bracelet:
7213 case iOldGlove:
7214 case iL2Ladder:
7215 case iWealthMedal:
7216 case iL2WealthMedal:
7217 case iL3WealthMedal:
7218 352 reset_itembuf(&tempitem, i);
7219 352 strcpy(item_string[i],old_item_string[i]);
7220 352 break;
7221
7222 case iSShield:
7223 16 reset_itembuf(&tempitem, i);
7224 16 strcpy(item_string[i],old_item_string[i]);
7225 16 strcpy(item_string[iShield],old_item_string[iShield]);
7226 16 strcpy(item_string[iMShield],old_item_string[iMShield]);
7227 16 break;
7228 }
7229 4096 }
7230
7231
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 5)
7232 {
7233
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 3984 times.
4096 switch(i)
7234 {
7235 case iHeartRing:
7236 case iL2HeartRing:
7237 case iL3HeartRing:
7238 case iMagicRing:
7239 case iL2MagicRing:
7240 case iL3MagicRing:
7241 case iL4MagicRing:
7242 112 reset_itembuf(&tempitem, i);
7243 112 strcpy(item_string[i],old_item_string[i]);
7244 112 break;
7245 }
7246 4096 }
7247
7248
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7249 {
7250
4/4
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4064 times.
4096 if(i!=iBPotion && i!=iRPotion)
7251 4064 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7252
7253
43/43
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 64 times.
✓ Branch 7 taken 3376 times.
✓ Branch 8 taken 16 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 16 times.
✓ Branch 12 taken 16 times.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 16 times.
✓ Branch 15 taken 16 times.
✓ Branch 16 taken 16 times.
✓ Branch 17 taken 16 times.
✓ Branch 18 taken 16 times.
✓ Branch 19 taken 16 times.
✓ Branch 20 taken 16 times.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 16 times.
✓ Branch 24 taken 16 times.
✓ Branch 25 taken 16 times.
✓ Branch 26 taken 16 times.
✓ Branch 27 taken 16 times.
✓ Branch 28 taken 16 times.
✓ Branch 29 taken 16 times.
✓ Branch 30 taken 16 times.
✓ Branch 31 taken 16 times.
✓ Branch 32 taken 16 times.
✓ Branch 33 taken 16 times.
✓ Branch 34 taken 16 times.
✓ Branch 35 taken 16 times.
✓ Branch 36 taken 16 times.
✓ Branch 37 taken 16 times.
✓ Branch 38 taken 16 times.
✓ Branch 39 taken 16 times.
✓ Branch 40 taken 16 times.
✓ Branch 41 taken 16 times.
✓ Branch 42 taken 16 times.
4096 switch(i)
7254 {
7255 case iTriforce:
7256 16 tempitem.fam_type=1;
7257 16 break;
7258
7259 case iBigTri:
7260 16 tempitem.fam_type=0;
7261 16 break;
7262
7263 case iBombs:
7264 16 tempitem.fam_type=i_bomb;
7265 16 tempitem.power=4;
7266 16 tempitem.wpn=wBOMB;
7267 16 tempitem.wpn2=wBOOM;
7268 16 tempitem.misc1 = 50;
7269
7270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7271
7272 16 break;
7273
7274 case iSBomb:
7275 16 tempitem.fam_type=i_sbomb;
7276 16 tempitem.power=16;
7277 16 tempitem.wpn=wSBOMB;
7278 16 tempitem.wpn2=wSBOOM;
7279 16 tempitem.misc1 = 50;
7280
7281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7282
7283 16 break;
7284
7285 case iBook:
7286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7287 tempitem.wpn = wFIREMAGIC;
7288
7289 16 break;
7290
7291 case iSArrow:
7292 16 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7293 16 tempitem.power=4;
7294 16 tempitem.flags|=ITEM_GAMEDATA;
7295 16 tempitem.wpn=wSARROW;
7296 16 break;
7297
7298 case iGArrow:
7299 16 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7300 16 tempitem.power=8;
7301 16 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7302 16 tempitem.wpn=wGARROW;
7303 16 break;
7304
7305 case iBrang:
7306 16 tempitem.power=0;
7307 16 tempitem.wpn=wBRANG;
7308 16 tempitem.misc1=36;
7309 16 break;
7310
7311 case iMBrang:
7312 16 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7313 16 tempitem.power=0;
7314 16 tempitem.wpn=wMBRANG;
7315 16 break;
7316
7317 case iFBrang:
7318 16 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7319 16 tempitem.power=2;
7320 16 tempitem.wpn=wFBRANG;
7321 16 break;
7322
7323 case iBoots:
7324 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7325 16 tempitem.power=7;
7326 16 break;
7327
7328 case iWand:
7329 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7330 16 tempitem.power=2;
7331 16 tempitem.wpn=wWAND;
7332 16 tempitem.wpn3=wMAGIC;
7333 16 break;
7334
7335 case iBCandle:
7336 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7337 16 tempitem.power=1;
7338 16 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7339 16 tempitem.wpn3=wFIRE;
7340 16 break;
7341
7342 case iRCandle:
7343 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7344 16 tempitem.power=1;
7345 16 tempitem.wpn3=wFIRE;
7346 16 break;
7347
7348 case iSword:
7349 16 tempitem.power=1;
7350 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7351 16 tempitem.wpn=tempitem.wpn3=wSWORD;
7352 16 tempitem.wpn2=wSWORDSLASH;
7353 16 break;
7354
7355 case iWSword:
7356 16 tempitem.power=2;
7357 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7358 16 tempitem.wpn=tempitem.wpn3=wWSWORD;
7359 16 tempitem.wpn2=wWSWORDSLASH;
7360 16 break;
7361
7362 case iMSword:
7363 16 tempitem.power=4;
7364 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7365 16 tempitem.wpn=tempitem.wpn3=wMSWORD;
7366 16 tempitem.wpn2=wMSWORDSLASH;
7367 16 break;
7368
7369 case iXSword:
7370 16 tempitem.power=8;
7371 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7372 16 tempitem.wpn=tempitem.wpn3=wXSWORD;
7373 16 tempitem.wpn2=wXSWORDSLASH;
7374 16 break;
7375
7376 case iDivineProtection:
7377 16 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG1 : 0;
7378 16 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG2 : 0;
7379 16 tempitem.wpn=wDIVINEPROTECTION1A;
7380 16 tempitem.wpn2=wDIVINEPROTECTION1B;
7381 16 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7382 16 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7383 16 tempitem.wpn6=wDIVINEPROTECTION2A;
7384 16 tempitem.wpn7=wDIVINEPROTECTION2B;
7385 16 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7386 16 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7387 16 tempitem.wpn5 = iwDivineProtectionShieldFront;
7388 16 tempitem.wpn10 = iwDivineProtectionShieldBack;
7389 16 tempitem.misc1=512;
7390 16 tempitem.cost_amount[0]=64;
7391 16 break;
7392
7393 case iLens:
7394 16 tempitem.misc1=60;
7395 16 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7396 16 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7397 16 break;
7398
7399 case iArrow:
7400 16 tempitem.power=2;
7401 16 tempitem.wpn=wARROW;
7402 16 break;
7403
7404 case iHoverBoots:
7405 16 tempitem.misc1=45;
7406 16 tempitem.wpn=iwHover;
7407 16 break;
7408
7409 case iDivineFire:
7410 16 tempitem.power=8;
7411 16 tempitem.wpn=wDIVINEFIRE1A;
7412 16 tempitem.wpn2=wDIVINEFIRE1B;
7413 16 tempitem.wpn3=wDIVINEFIRES1A;
7414 16 tempitem.wpn4=wDIVINEFIRES1B;
7415 16 tempitem.misc1 = 32;
7416 16 tempitem.misc2 = 200;
7417 16 tempitem.cost_amount[0]=32;
7418 16 break;
7419
7420 case iDivineEscape:
7421 16 tempitem.cost_amount[0]=32;
7422 16 break;
7423
7424 case iHookshot:
7425 16 tempitem.power=0;
7426 16 tempitem.flags&=~ITEM_FLAG1;
7427 16 tempitem.wpn=wHSHEAD;
7428 16 tempitem.wpn2=wHSCHAIN_H;
7429 16 tempitem.wpn4=wHSHANDLE;
7430 16 tempitem.wpn3=wHSCHAIN_V;
7431 16 tempitem.misc1=50;
7432 16 tempitem.misc2=100;
7433 16 break;
7434
7435 case iLongshot:
7436 16 tempitem.power=0;
7437 16 tempitem.flags&=~ITEM_FLAG1;
7438 16 tempitem.wpn=wLSHEAD;
7439 16 tempitem.wpn2=wLSCHAIN_H;
7440 16 tempitem.wpn4=wLSHANDLE;
7441 16 tempitem.wpn3=wLSCHAIN_V;
7442 16 tempitem.misc1=99;
7443 16 tempitem.misc2=100;
7444 16 break;
7445
7446 case iHammer:
7447 16 tempitem.power=4;
7448 16 tempitem.wpn=wHAMMER;
7449 16 tempitem.wpn2=iwHammerSmack;
7450 16 break;
7451
7452 case iCByrna:
7453 16 tempitem.power=1;
7454 16 tempitem.wpn=wCBYRNA;
7455 16 tempitem.wpn2=wCBYRNASLASH;
7456 16 tempitem.wpn3=wCBYRNAORB;
7457 16 tempitem.misc1=4;
7458 16 tempitem.misc2=16;
7459 16 tempitem.misc3=1;
7460 16 tempitem.cost_amount[0]=1;
7461 16 break;
7462
7463 case iWhistle:
7464 16 tempitem.wpn=wWIND;
7465 16 tempitem.misc1=3;
7466 16 tempitem.flags|=ITEM_FLAG1;
7467 16 break;
7468
7469 case iBRing:
7470 16 tempitem.power=2;
7471 16 tempitem.misc1=spBLUE;
7472 16 break;
7473
7474 case iRRing:
7475 16 tempitem.power=4;
7476 16 tempitem.misc1=spRED;
7477 16 break;
7478
7479 case iGRing:
7480 16 tempitem.power=8;
7481 16 tempitem.misc1=spGOLD;
7482 16 break;
7483
7484 case iSpinScroll:
7485 16 tempitem.power = 2;
7486 16 tempitem.misc1 = 1;
7487 16 break;
7488
7489 case iL2SpinScroll:
7490 16 tempitem.family=itype_spinscroll2;
7491 16 tempitem.fam_type=1;
7492 16 tempitem.cost_amount[0]=8;
7493 16 tempitem.power=2;
7494 16 tempitem.misc1 = 20;
7495 16 break;
7496
7497 case iQuakeScroll:
7498 16 tempitem.misc1=0x10;
7499 16 tempitem.misc2=64;
7500 16 break;
7501
7502 case iL2QuakeScroll:
7503 16 tempitem.family=itype_quakescroll2;
7504 16 tempitem.fam_type=1;
7505 16 tempitem.power = 2;
7506 16 tempitem.misc1=0x20;
7507 16 tempitem.misc2=192;
7508 16 tempitem.cost_amount[0]=8;
7509 16 break;
7510
7511 case iChargeRing:
7512 16 tempitem.misc1=64;
7513 16 tempitem.misc2=128;
7514 16 break;
7515
7516 case iL2ChargeRing:
7517 16 tempitem.misc1=32;
7518 16 tempitem.misc2=64;
7519 16 break;
7520
7521 case iOldGlove:
7522 16 tempitem.flags |= ITEM_FLAG1;
7523
7524 //fallthrough
7525 case iBombBagL4:
7526 case iWalletL3:
7527 case iQuiverL4:
7528 case iBracelet:
7529 80 tempitem.power = 1;
7530 80 break;
7531
7532 case iL2Bracelet:
7533 16 tempitem.power = 2;
7534 16 break;
7535
7536 case iMKey:
7537 16 tempitem.power=0xFF;
7538 16 tempitem.flags |= ITEM_FLAG1;
7539 16 break;
7540 }
7541 4096 }
7542
7543
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 7)
7544 {
7545
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4032 times.
4096 switch(i)
7546 {
7547 case iStoneAgony:
7548 case iStompBoots:
7549 case iPerilRing:
7550 case iWhimsicalRing:
7551 {
7552 64 reset_itembuf(&tempitem, i);
7553 64 strcpy(item_string[i],old_item_string[i]);
7554 64 break;
7555 }
7556 }
7557 4096 }
7558
7559
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 8) // May 2007: Some corrections.
7560 {
7561
7/7
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 3968 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
4096 switch(i)
7562 {
7563 case iMShield:
7564 16 tempitem.misc1|=shFLAME;
7565 16 tempitem.misc2|=shFIREBALL|shMAGIC;
7566
7567
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_qr(qr_SWORDMIRROR))
7568 {
7569 tempitem.misc2 |= shSWORD;
7570 }
7571
7572 // fallthrough
7573 case iShield:
7574 32 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7575
7576 // fallthrough
7577 case iSShield:
7578 48 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7579
7580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7581 {
7582 tempitem.misc2 |= shROCK;
7583 }
7584
7585 48 break;
7586
7587 case iWhispRing:
7588 16 tempitem.power=1;
7589 16 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7590 16 tempitem.misc1 = 3;
7591 16 break;
7592
7593 case iL2WhispRing:
7594 16 tempitem.power=0;
7595 16 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7596 16 tempitem.misc1 = 3;
7597 16 break;
7598
7599 case iL2Ladder:
7600 case iBow:
7601 case iCByrna:
7602 48 tempitem.power = 1;
7603 48 break;
7604 }
7605 4096 }
7606
7607
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 28672 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
32768 if(s_version < 9 && i==iClock)
7608 {
7609 16 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7610 16 }
7611
7612 //add the misc flag for bomb
7613
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 28672 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
32768 if(s_version < 10 && tempitem.family == itype_bomb)
7614 {
7615 16 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7616 16 }
7617
7618
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 28672 times.
✓ Branch 2 taken 4064 times.
✓ Branch 3 taken 32 times.
32768 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7619 {
7620 32 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7621 32 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7622 32 }
7623
7624
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 12) // June 2007: More Misc. attributes.
7625 {
7626
5/5
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4016 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
4096 switch(i)
7627 {
7628 case iFBrang:
7629 16 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7630
7631 //fallthrough
7632 case iMBrang:
7633 32 tempitem.misc3 |= shSWORD|shMAGIC;
7634
7635 //fallthrough
7636 case iHookshot:
7637 case iLongshot:
7638 //fallthrough
7639 64 tempitem.misc3 |= shFIREBALL;
7640
7641 case iBrang:
7642 80 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7643 80 break;
7644 }
7645
7646
16/16
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 64 times.
✓ Branch 6 taken 32 times.
✓ Branch 7 taken 1956 times.
✓ Branch 8 taken 16 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 32 times.
✓ Branch 11 taken 48 times.
✓ Branch 12 taken 48 times.
✓ Branch 13 taken 1740 times.
✓ Branch 14 taken 16 times.
✓ Branch 15 taken 16 times.
4096 switch(tempitem.family)
7647 {
7648 case itype_hoverboots:
7649 16 tempitem.usesound = WAV_ZN1HOVER;
7650 16 break;
7651
7652 case itype_wand:
7653 16 tempitem.usesound = WAV_WAND;
7654 16 break;
7655
7656 case itype_book:
7657 16 tempitem.usesound = WAV_FIRE;
7658 16 break;
7659
7660 case itype_arrow:
7661 48 tempitem.usesound = WAV_ARROW;
7662 48 break;
7663
7664 case itype_hookshot:
7665 32 tempitem.usesound = WAV_HOOKSHOT;
7666 32 break;
7667
7668 case itype_brang:
7669 48 tempitem.usesound = WAV_BRANG;
7670 48 break;
7671
7672 case itype_shield:
7673 48 tempitem.usesound = WAV_CHINK;
7674 48 break;
7675
7676 case itype_sword:
7677 1740 tempitem.usesound = WAV_SWORD;
7678 1740 break;
7679
7680 case itype_whistle:
7681 16 tempitem.usesound = WAV_WHISTLE;
7682 16 break;
7683
7684 case itype_hammer:
7685 16 tempitem.usesound = WAV_HAMMER;
7686 16 break;
7687
7688 case itype_divinefire:
7689 16 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7690 16 break;
7691
7692 case itype_divineescape:
7693 16 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7694 16 break;
7695
7696 case itype_divineprotection:
7697 16 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7698 16 break;
7699
7700 case itype_bomb:
7701 case itype_sbomb:
7702 case itype_quakescroll:
7703 case itype_quakescroll2:
7704 64 tempitem.usesound = WAV_BOMB;
7705 64 break;
7706
7707 case itype_spinscroll:
7708 case itype_spinscroll2:
7709 32 tempitem.usesound = WAV_ZN1SPINATTACK;
7710 32 break;
7711 }
7712 4096 }
7713
7714
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 13) // July 2007
7715 {
7716
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_whistle)
7717 {
7718 16 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7719 16 tempitem.power = 1;
7720 16 tempitem.flags|=ITEM_FLAG1;
7721 16 }
7722
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4064 times.
4080 else if(tempitem.family == itype_wand)
7723 16 tempitem.flags|=ITEM_FLAG1;
7724
2/2
✓ Branch 0 taken 4048 times.
✓ Branch 1 taken 16 times.
4064 else if(tempitem.family == itype_book)
7725 {
7726 16 tempitem.flags|=ITEM_FLAG1;
7727 16 tempitem.power = 2;
7728 16 }
7729 4096 }
7730
7731
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 14) // August 2007
7732 {
7733
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4064 times.
4096 if(tempitem.family == itype_fairy)
7734 {
7735 32 tempitem.usesound = WAV_SCALE;
7736
7737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(tempitem.fam_type)
7738 32 tempitem.misc3=50;
7739 32 }
7740
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 32 times.
4064 else if(tempitem.family == itype_potion)
7741 {
7742 32 tempitem.flags |= ITEM_GAINOLD;
7743 32 }
7744 4096 }
7745
7746
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 17) // November 2007
7747 {
7748
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
4096 if(tempitem.family == itype_candle && !tempitem.wpn3)
7749 {
7750 tempitem.wpn3 = wFIRE;
7751 }
7752
4/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 4048 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 16 times.
4096 else if(tempitem.family == itype_arrow && tempitem.power>4)
7753 {
7754 16 tempitem.flags|=ITEM_FLAG1;
7755 16 }
7756 4096 }
7757
7758
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 18) // New Year's Eve 2007
7759 {
7760
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_whistle)
7761 16 tempitem.misc2 = 8; // Use the Whistle warp ring
7762
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4064 times.
4080 else if(tempitem.family == itype_bait)
7763 16 tempitem.misc1 = 768; // Frames until it goes
7764
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 32 times.
4064 else if(tempitem.family == itype_triforcepiece)
7765 {
7766
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
32 if(tempitem.flags & ITEM_GAMEDATA)
7767 {
7768 16 tempitem.misc2 = 1; // Cutscene 1
7769 16 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7770 16 }
7771 32 }
7772 4096 }
7773
7774
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 19) // January 2008
7775 {
7776
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divineprotection)
7777 {
7778 16 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7779 16 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7780 16 }
7781 4096 }
7782
7783
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 20) // October 2008
7784 {
7785
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divineprotection)
7786 {
7787 16 tempitem.wpn6=wDIVINEPROTECTION2A;
7788 16 tempitem.wpn7=wDIVINEPROTECTION2B;
7789 16 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7790 16 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7791 16 tempitem.wpn5 = iwDivineProtectionShieldFront;
7792 16 tempitem.wpn10 = iwDivineProtectionShieldBack;
7793 16 }
7794 4096 }
7795
7796
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 21) // November 2008
7797 {
7798
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(tempitem.flags & 0x0100) // ITEM_SLASH
7799 {
7800 tempitem.flags &= ~0x0100;
7801
7802 if(tempitem.family == itype_sword ||
7803 tempitem.family == itype_wand ||
7804 tempitem.family == itype_candle ||
7805 tempitem.family == itype_cbyrna)
7806 {
7807 tempitem.flags |= ITEM_FLAG4;
7808 }
7809 }
7810 4096 }
7811
7812
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 22) // September 2009
7813 {
7814
4/4
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4064 times.
4096 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7815 {
7816 32 tempitem.misc3 = tempitem.power/2;
7817 32 }
7818 4096 }
7819
7820
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 23) // March 2011
7821 {
7822
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_divinefire)
7823 16 tempitem.wpn5 = wFIRE;
7824
2/2
✓ Branch 0 taken 4064 times.
✓ Branch 1 taken 16 times.
4080 else if(tempitem.family == itype_book)
7825 16 tempitem.wpn2 = wFIRE;
7826 4096 }
7827
7828 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7829 // whether it was or not, and a lot of existing quests depended on the
7830 // incorrect behavior.
7831
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 25) // January 2012
7832 {
7833
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 64 times.
4096 if(tempitem.family == itype_bombbag)
7834 64 tempitem.flags |= 16;
7835
7836
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divinefire)
7837 16 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7838 4096 }
7839
7840
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7841 {
7842
60/60
✓ Branch 0 taken 7811 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 274 times.
✓ Branch 3 taken 222 times.
✓ Branch 4 taken 138 times.
✓ Branch 5 taken 93 times.
✓ Branch 6 taken 184 times.
✓ Branch 7 taken 183 times.
✓ Branch 8 taken 107 times.
✓ Branch 9 taken 302 times.
✓ Branch 10 taken 276 times.
✓ Branch 11 taken 183 times.
✓ Branch 12 taken 283 times.
✓ Branch 13 taken 184 times.
✓ Branch 14 taken 92 times.
✓ Branch 15 taken 184 times.
✓ Branch 16 taken 107 times.
✓ Branch 17 taken 92 times.
✓ Branch 18 taken 279 times.
✓ Branch 19 taken 93 times.
✓ Branch 20 taken 94 times.
✓ Branch 21 taken 184 times.
✓ Branch 22 taken 92 times.
✓ Branch 23 taken 93 times.
✓ Branch 24 taken 92 times.
✓ Branch 25 taken 92 times.
✓ Branch 26 taken 92 times.
✓ Branch 27 taken 107 times.
✓ Branch 28 taken 92 times.
✓ Branch 29 taken 93 times.
✓ Branch 30 taken 92 times.
✓ Branch 31 taken 93 times.
✓ Branch 32 taken 184 times.
✓ Branch 33 taken 368 times.
✓ Branch 34 taken 94 times.
✓ Branch 35 taken 92 times.
✓ Branch 36 taken 168 times.
✓ Branch 37 taken 368 times.
✓ Branch 38 taken 92 times.
✓ Branch 39 taken 92 times.
✓ Branch 40 taken 92 times.
✓ Branch 41 taken 92 times.
✓ Branch 42 taken 92 times.
✓ Branch 43 taken 185 times.
✓ Branch 44 taken 184 times.
✓ Branch 45 taken 92 times.
✓ Branch 46 taken 277 times.
✓ Branch 47 taken 278 times.
✓ Branch 48 taken 372 times.
✓ Branch 49 taken 92 times.
✓ Branch 50 taken 92 times.
✓ Branch 51 taken 92 times.
✓ Branch 52 taken 92 times.
✓ Branch 53 taken 92 times.
✓ Branch 54 taken 93 times.
✓ Branch 55 taken 2541 times.
✓ Branch 56 taken 983 times.
✓ Branch 57 taken 277 times.
✓ Branch 58 taken 1135 times.
✓ Branch 59 taken 2617 times.
23808 switch(tempitem.family)
7843 {
7844 case itype_sword:
7845 {
7846 7811 tempitem.flags &= ~(ITEM_FLAG5);
7847 7811 tempitem.misc3 = 0;
7848 7811 tempitem.misc4 = 0;
7849 7811 tempitem.misc5 = 0;
7850 7811 tempitem.misc6 = 0;
7851 7811 tempitem.misc7 = 0;
7852 7811 tempitem.misc8 = 0;
7853 7811 tempitem.misc9 = 0;
7854 7811 tempitem.misc10 = 0;
7855 7811 tempitem.wpn4 = 0;
7856 7811 tempitem.wpn5 = 0;
7857 7811 tempitem.wpn6 = 0;
7858 7811 tempitem.wpn7 = 0;
7859 7811 tempitem.wpn8 = 0;
7860 7811 tempitem.wpn9 = 0;
7861 7811 tempitem.wpn10 = 0;
7862 7811 break;
7863 }
7864 case itype_brang:
7865 {
7866 277 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7867 277 tempitem.misc2 = 0;
7868 277 tempitem.misc5 = 0;
7869 277 tempitem.misc6 = 0;
7870 277 tempitem.misc7 = 0;
7871 277 tempitem.misc8 = 0;
7872 277 tempitem.misc9 = 0;
7873 277 tempitem.misc10 = 0;
7874 277 tempitem.wpn4 = 0;
7875 277 tempitem.wpn5 = 0;
7876 277 tempitem.wpn6 = 0;
7877 277 tempitem.wpn7 = 0;
7878 277 tempitem.wpn8 = 0;
7879 277 tempitem.wpn9 = 0;
7880 277 tempitem.wpn10 = 0;
7881 277 break;
7882 }
7883 case itype_arrow:
7884 {
7885 274 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7886 274 tempitem.misc2 = 0;
7887 274 tempitem.misc3 = 0;
7888 274 tempitem.misc4 = 0;
7889 274 tempitem.misc5 = 0;
7890 274 tempitem.misc6 = 0;
7891 274 tempitem.misc7 = 0;
7892 274 tempitem.misc8 = 0;
7893 274 tempitem.misc9 = 0;
7894 274 tempitem.misc10 = 0;
7895 274 tempitem.wpn4 = 0;
7896 274 tempitem.wpn5 = 0;
7897 274 tempitem.wpn6 = 0;
7898 274 tempitem.wpn7 = 0;
7899 274 tempitem.wpn8 = 0;
7900 274 tempitem.wpn9 = 0;
7901 274 tempitem.wpn10 = 0;
7902 274 break;
7903 }
7904 case itype_candle:
7905 {
7906 222 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7907 222 tempitem.misc1 = 0;
7908 222 tempitem.misc2 = 0;
7909 222 tempitem.misc3 = 0;
7910 222 tempitem.misc4 = 0;
7911 222 tempitem.misc5 = 0;
7912 222 tempitem.misc6 = 0;
7913 222 tempitem.misc7 = 0;
7914 222 tempitem.misc8 = 0;
7915 222 tempitem.misc9 = 0;
7916 222 tempitem.misc10 = 0;
7917 222 tempitem.wpn4 = 0;
7918 222 tempitem.wpn5 = 0;
7919 222 tempitem.wpn6 = 0;
7920 222 tempitem.wpn7 = 0;
7921 222 tempitem.wpn8 = 0;
7922 222 tempitem.wpn9 = 0;
7923 222 tempitem.wpn10 = 0;
7924 222 break;
7925 }
7926 case itype_whistle:
7927 {
7928 138 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7929 138 tempitem.misc3 = 0;
7930 138 tempitem.misc4 = 0;
7931 138 tempitem.misc5 = 0;
7932 138 tempitem.misc6 = 0;
7933 138 tempitem.misc7 = 0;
7934 138 tempitem.misc8 = 0;
7935 138 tempitem.misc9 = 0;
7936 138 tempitem.misc10 = 0;
7937 138 tempitem.wpn2 = 0;
7938 138 tempitem.wpn3 = 0;
7939 138 tempitem.wpn4 = 0;
7940 138 tempitem.wpn5 = 0;
7941 138 tempitem.wpn6 = 0;
7942 138 tempitem.wpn7 = 0;
7943 138 tempitem.wpn8 = 0;
7944 138 tempitem.wpn9 = 0;
7945 138 tempitem.wpn10 = 0;
7946 138 break;
7947 }
7948 case itype_bait:
7949 {
7950 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7951 93 tempitem.misc2 = 0;
7952 93 tempitem.misc3 = 0;
7953 93 tempitem.misc4 = 0;
7954 93 tempitem.misc5 = 0;
7955 93 tempitem.misc6 = 0;
7956 93 tempitem.misc7 = 0;
7957 93 tempitem.misc8 = 0;
7958 93 tempitem.misc9 = 0;
7959 93 tempitem.misc10 = 0;
7960 93 tempitem.wpn2 = 0;
7961 93 tempitem.wpn3 = 0;
7962 93 tempitem.wpn4 = 0;
7963 93 tempitem.wpn5 = 0;
7964 93 tempitem.wpn6 = 0;
7965 93 tempitem.wpn7 = 0;
7966 93 tempitem.wpn8 = 0;
7967 93 tempitem.wpn9 = 0;
7968 93 tempitem.wpn10 = 0;
7969 93 break;
7970 }
7971 case itype_letter:
7972 {
7973 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7974 184 tempitem.misc1 = 0;
7975 184 tempitem.misc2 = 0;
7976 184 tempitem.misc3 = 0;
7977 184 tempitem.misc4 = 0;
7978 184 tempitem.misc5 = 0;
7979 184 tempitem.misc6 = 0;
7980 184 tempitem.misc7 = 0;
7981 184 tempitem.misc8 = 0;
7982 184 tempitem.misc9 = 0;
7983 184 tempitem.misc10 = 0;
7984 184 tempitem.wpn = 0;
7985 184 tempitem.wpn2 = 0;
7986 184 tempitem.wpn3 = 0;
7987 184 tempitem.wpn4 = 0;
7988 184 tempitem.wpn5 = 0;
7989 184 tempitem.wpn6 = 0;
7990 184 tempitem.wpn7 = 0;
7991 184 tempitem.wpn8 = 0;
7992 184 tempitem.wpn9 = 0;
7993 184 tempitem.wpn10 = 0;
7994 184 break;
7995 }
7996 case itype_potion:
7997 {
7998 183 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7999 183 tempitem.misc3 = 0;
8000 183 tempitem.misc4 = 0;
8001 183 tempitem.misc5 = 0;
8002 183 tempitem.misc6 = 0;
8003 183 tempitem.misc7 = 0;
8004 183 tempitem.misc8 = 0;
8005 183 tempitem.misc9 = 0;
8006 183 tempitem.misc10 = 0;
8007 183 tempitem.wpn = 0;
8008 183 tempitem.wpn2 = 0;
8009 183 tempitem.wpn3 = 0;
8010 183 tempitem.wpn4 = 0;
8011 183 tempitem.wpn5 = 0;
8012 183 tempitem.wpn6 = 0;
8013 183 tempitem.wpn7 = 0;
8014 183 tempitem.wpn8 = 0;
8015 183 tempitem.wpn9 = 0;
8016 183 tempitem.wpn10 = 0;
8017 183 break;
8018 }
8019 case itype_wand:
8020 {
8021 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8022 107 tempitem.misc1 = 0;
8023 107 tempitem.misc2 = 0;
8024 107 tempitem.misc3 = 0;
8025 107 tempitem.misc4 = 0;
8026 107 tempitem.misc5 = 0;
8027 107 tempitem.misc6 = 0;
8028 107 tempitem.misc7 = 0;
8029 107 tempitem.misc8 = 0;
8030 107 tempitem.misc9 = 0;
8031 107 tempitem.misc10 = 0;
8032 107 tempitem.wpn4 = 0;
8033 107 tempitem.wpn5 = 0;
8034 107 tempitem.wpn6 = 0;
8035 107 tempitem.wpn7 = 0;
8036 107 tempitem.wpn8 = 0;
8037 107 tempitem.wpn9 = 0;
8038 107 tempitem.wpn10 = 0;
8039 107 break;
8040 }
8041 case itype_ring:
8042 {
8043 302 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8044 302 tempitem.misc2 = 0;
8045 302 tempitem.misc3 = 0;
8046 302 tempitem.misc4 = 0;
8047 302 tempitem.misc5 = 0;
8048 302 tempitem.misc6 = 0;
8049 302 tempitem.misc7 = 0;
8050 302 tempitem.misc8 = 0;
8051 302 tempitem.misc9 = 0;
8052 302 tempitem.misc10 = 0;
8053 302 tempitem.wpn = 0;
8054 302 tempitem.wpn2 = 0;
8055 302 tempitem.wpn3 = 0;
8056 302 tempitem.wpn4 = 0;
8057 302 tempitem.wpn5 = 0;
8058 302 tempitem.wpn6 = 0;
8059 302 tempitem.wpn7 = 0;
8060 302 tempitem.wpn8 = 0;
8061 302 tempitem.wpn9 = 0;
8062 302 tempitem.wpn10 = 0;
8063 302 break;
8064 }
8065 case itype_wallet:
8066 {
8067 276 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8068 276 tempitem.misc3 = 0;
8069 276 tempitem.misc4 = 0;
8070 276 tempitem.misc5 = 0;
8071 276 tempitem.misc6 = 0;
8072 276 tempitem.misc7 = 0;
8073 276 tempitem.misc8 = 0;
8074 276 tempitem.misc9 = 0;
8075 276 tempitem.misc10 = 0;
8076 276 tempitem.wpn = 0;
8077 276 tempitem.wpn2 = 0;
8078 276 tempitem.wpn3 = 0;
8079 276 tempitem.wpn4 = 0;
8080 276 tempitem.wpn5 = 0;
8081 276 tempitem.wpn6 = 0;
8082 276 tempitem.wpn7 = 0;
8083 276 tempitem.wpn8 = 0;
8084 276 tempitem.wpn9 = 0;
8085 276 tempitem.wpn10 = 0;
8086 276 break;
8087 }
8088 case itype_amulet:
8089 {
8090 183 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8091 183 tempitem.misc1 = 0;
8092 183 tempitem.misc2 = 0;
8093 183 tempitem.misc3 = 0;
8094 183 tempitem.misc4 = 0;
8095 183 tempitem.misc5 = 0;
8096 183 tempitem.misc6 = 0;
8097 183 tempitem.misc7 = 0;
8098 183 tempitem.misc8 = 0;
8099 183 tempitem.misc9 = 0;
8100 183 tempitem.misc10 = 0;
8101 183 tempitem.wpn = 0;
8102 183 tempitem.wpn2 = 0;
8103 183 tempitem.wpn3 = 0;
8104 183 tempitem.wpn4 = 0;
8105 183 tempitem.wpn5 = 0;
8106 183 tempitem.wpn6 = 0;
8107 183 tempitem.wpn7 = 0;
8108 183 tempitem.wpn8 = 0;
8109 183 tempitem.wpn9 = 0;
8110 183 tempitem.wpn10 = 0;
8111 183 break;
8112 }
8113 case itype_shield:
8114 {
8115 283 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8116 283 tempitem.misc3 = 0;
8117 283 tempitem.misc4 = 0;
8118 283 tempitem.misc5 = 0;
8119 283 tempitem.misc6 = 0;
8120 283 tempitem.misc7 = 0;
8121 283 tempitem.misc8 = 0;
8122 283 tempitem.misc9 = 0;
8123 283 tempitem.misc10 = 0;
8124 283 tempitem.wpn = 0;
8125 283 tempitem.wpn2 = 0;
8126 283 tempitem.wpn3 = 0;
8127 283 tempitem.wpn4 = 0;
8128 283 tempitem.wpn5 = 0;
8129 283 tempitem.wpn6 = 0;
8130 283 tempitem.wpn7 = 0;
8131 283 tempitem.wpn8 = 0;
8132 283 tempitem.wpn9 = 0;
8133 283 tempitem.wpn10 = 0;
8134 283 break;
8135 }
8136 case itype_bow:
8137 {
8138 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8139 184 tempitem.misc1 = 0;
8140 184 tempitem.misc2 = 0;
8141 184 tempitem.misc3 = 0;
8142 184 tempitem.misc4 = 0;
8143 184 tempitem.misc5 = 0;
8144 184 tempitem.misc6 = 0;
8145 184 tempitem.misc7 = 0;
8146 184 tempitem.misc8 = 0;
8147 184 tempitem.misc9 = 0;
8148 184 tempitem.misc10 = 0;
8149 184 tempitem.wpn = 0;
8150 184 tempitem.wpn2 = 0;
8151 184 tempitem.wpn3 = 0;
8152 184 tempitem.wpn4 = 0;
8153 184 tempitem.wpn5 = 0;
8154 184 tempitem.wpn6 = 0;
8155 184 tempitem.wpn7 = 0;
8156 184 tempitem.wpn8 = 0;
8157 184 tempitem.wpn9 = 0;
8158 184 tempitem.wpn10 = 0;
8159 184 break;
8160 }
8161 case itype_raft:
8162 {
8163 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8164 92 tempitem.misc1 = 0;
8165 92 tempitem.misc2 = 0;
8166 92 tempitem.misc3 = 0;
8167 92 tempitem.misc4 = 0;
8168 92 tempitem.misc5 = 0;
8169 92 tempitem.misc6 = 0;
8170 92 tempitem.misc7 = 0;
8171 92 tempitem.misc8 = 0;
8172 92 tempitem.misc9 = 0;
8173 92 tempitem.misc10 = 0;
8174 92 tempitem.wpn = 0;
8175 92 tempitem.wpn2 = 0;
8176 92 tempitem.wpn3 = 0;
8177 92 tempitem.wpn4 = 0;
8178 92 tempitem.wpn5 = 0;
8179 92 tempitem.wpn6 = 0;
8180 92 tempitem.wpn7 = 0;
8181 92 tempitem.wpn8 = 0;
8182 92 tempitem.wpn9 = 0;
8183 92 tempitem.wpn10 = 0;
8184 92 break;
8185 }
8186 case itype_ladder:
8187 {
8188 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8189 184 tempitem.misc1 = 0;
8190 184 tempitem.misc2 = 0;
8191 184 tempitem.misc3 = 0;
8192 184 tempitem.misc4 = 0;
8193 184 tempitem.misc5 = 0;
8194 184 tempitem.misc6 = 0;
8195 184 tempitem.misc7 = 0;
8196 184 tempitem.misc8 = 0;
8197 184 tempitem.misc9 = 0;
8198 184 tempitem.misc10 = 0;
8199 184 tempitem.wpn = 0;
8200 184 tempitem.wpn2 = 0;
8201 184 tempitem.wpn3 = 0;
8202 184 tempitem.wpn4 = 0;
8203 184 tempitem.wpn5 = 0;
8204 184 tempitem.wpn6 = 0;
8205 184 tempitem.wpn7 = 0;
8206 184 tempitem.wpn8 = 0;
8207 184 tempitem.wpn9 = 0;
8208 184 tempitem.wpn10 = 0;
8209 184 break;
8210 }
8211 case itype_book:
8212 {
8213 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8214 107 tempitem.misc1 = 0;
8215 107 tempitem.misc2 = 0;
8216 107 tempitem.misc3 = 0;
8217 107 tempitem.misc4 = 0;
8218 107 tempitem.misc5 = 0;
8219 107 tempitem.misc6 = 0;
8220 107 tempitem.misc7 = 0;
8221 107 tempitem.misc8 = 0;
8222 107 tempitem.misc9 = 0;
8223 107 tempitem.misc10 = 0;
8224 107 tempitem.wpn3 = 0;
8225 107 tempitem.wpn4 = 0;
8226 107 tempitem.wpn5 = 0;
8227 107 tempitem.wpn6 = 0;
8228 107 tempitem.wpn7 = 0;
8229 107 tempitem.wpn8 = 0;
8230 107 tempitem.wpn9 = 0;
8231 107 tempitem.wpn10 = 0;
8232 107 break;
8233 }
8234 case itype_magickey:
8235 {
8236 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8237 92 tempitem.misc1 = 0;
8238 92 tempitem.misc2 = 0;
8239 92 tempitem.misc3 = 0;
8240 92 tempitem.misc4 = 0;
8241 92 tempitem.misc5 = 0;
8242 92 tempitem.misc6 = 0;
8243 92 tempitem.misc7 = 0;
8244 92 tempitem.misc8 = 0;
8245 92 tempitem.misc9 = 0;
8246 92 tempitem.misc10 = 0;
8247 92 tempitem.wpn = 0;
8248 92 tempitem.wpn2 = 0;
8249 92 tempitem.wpn3 = 0;
8250 92 tempitem.wpn4 = 0;
8251 92 tempitem.wpn5 = 0;
8252 92 tempitem.wpn6 = 0;
8253 92 tempitem.wpn7 = 0;
8254 92 tempitem.wpn8 = 0;
8255 92 tempitem.wpn9 = 0;
8256 92 tempitem.wpn10 = 0;
8257 92 break;
8258 }
8259 case itype_bracelet:
8260 {
8261 279 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8262 279 tempitem.misc1 = 0;
8263 279 tempitem.misc2 = 0;
8264 279 tempitem.misc3 = 0;
8265 279 tempitem.misc4 = 0;
8266 279 tempitem.misc5 = 0;
8267 279 tempitem.misc6 = 0;
8268 279 tempitem.misc7 = 0;
8269 279 tempitem.misc8 = 0;
8270 279 tempitem.misc9 = 0;
8271 279 tempitem.misc10 = 0;
8272 279 tempitem.wpn = 0;
8273 279 tempitem.wpn2 = 0;
8274 279 tempitem.wpn3 = 0;
8275 279 tempitem.wpn4 = 0;
8276 279 tempitem.wpn5 = 0;
8277 279 tempitem.wpn6 = 0;
8278 279 tempitem.wpn7 = 0;
8279 279 tempitem.wpn8 = 0;
8280 279 tempitem.wpn9 = 0;
8281 279 tempitem.wpn10 = 0;
8282 279 break;
8283 }
8284 case itype_flippers:
8285 {
8286 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8287 93 tempitem.misc1 = 0;
8288 93 tempitem.misc2 = 0;
8289 93 tempitem.misc3 = 0;
8290 93 tempitem.misc4 = 0;
8291 93 tempitem.misc5 = 0;
8292 93 tempitem.misc6 = 0;
8293 93 tempitem.misc7 = 0;
8294 93 tempitem.misc8 = 0;
8295 93 tempitem.misc9 = 0;
8296 93 tempitem.misc10 = 0;
8297 93 tempitem.wpn = 0;
8298 93 tempitem.wpn2 = 0;
8299 93 tempitem.wpn3 = 0;
8300 93 tempitem.wpn4 = 0;
8301 93 tempitem.wpn5 = 0;
8302 93 tempitem.wpn6 = 0;
8303 93 tempitem.wpn7 = 0;
8304 93 tempitem.wpn8 = 0;
8305 93 tempitem.wpn9 = 0;
8306 93 tempitem.wpn10 = 0;
8307 93 break;
8308 }
8309 case itype_boots:
8310 {
8311 94 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8312 94 tempitem.misc1 = 0;
8313 94 tempitem.misc2 = 0;
8314 94 tempitem.misc3 = 0;
8315 94 tempitem.misc4 = 0;
8316 94 tempitem.misc5 = 0;
8317 94 tempitem.misc6 = 0;
8318 94 tempitem.misc7 = 0;
8319 94 tempitem.misc8 = 0;
8320 94 tempitem.misc9 = 0;
8321 94 tempitem.misc10 = 0;
8322 94 tempitem.wpn = 0;
8323 94 tempitem.wpn2 = 0;
8324 94 tempitem.wpn3 = 0;
8325 94 tempitem.wpn4 = 0;
8326 94 tempitem.wpn5 = 0;
8327 94 tempitem.wpn6 = 0;
8328 94 tempitem.wpn7 = 0;
8329 94 tempitem.wpn8 = 0;
8330 94 tempitem.wpn9 = 0;
8331 94 tempitem.wpn10 = 0;
8332 94 break;
8333 }
8334 case itype_hookshot:
8335 {
8336 184 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8337 184 tempitem.misc5 = 0;
8338 184 tempitem.misc6 = 0;
8339 184 tempitem.misc7 = 0;
8340 184 tempitem.misc8 = 0;
8341 184 tempitem.misc9 = 0;
8342 184 tempitem.misc10 = 0;
8343 184 tempitem.wpn5 = 0;
8344 184 tempitem.wpn6 = 0;
8345 184 tempitem.wpn7 = 0;
8346 184 tempitem.wpn8 = 0;
8347 184 tempitem.wpn9 = 0;
8348 184 tempitem.wpn10 = 0;
8349 184 break;
8350 }
8351 case itype_lens:
8352 {
8353 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8354 92 tempitem.misc2 = 0;
8355 92 tempitem.misc3 = 0;
8356 92 tempitem.misc4 = 0;
8357 92 tempitem.misc5 = 0;
8358 92 tempitem.misc6 = 0;
8359 92 tempitem.misc7 = 0;
8360 92 tempitem.misc8 = 0;
8361 92 tempitem.misc9 = 0;
8362 92 tempitem.misc10 = 0;
8363 92 tempitem.wpn = 0;
8364 92 tempitem.wpn2 = 0;
8365 92 tempitem.wpn3 = 0;
8366 92 tempitem.wpn4 = 0;
8367 92 tempitem.wpn5 = 0;
8368 92 tempitem.wpn6 = 0;
8369 92 tempitem.wpn7 = 0;
8370 92 tempitem.wpn8 = 0;
8371 92 tempitem.wpn9 = 0;
8372 92 tempitem.wpn10 = 0;
8373 92 break;
8374 }
8375 case itype_hammer:
8376 {
8377 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8378 93 tempitem.misc1 = 0;
8379 93 tempitem.misc2 = 0;
8380 93 tempitem.misc3 = 0;
8381 93 tempitem.misc4 = 0;
8382 93 tempitem.misc5 = 0;
8383 93 tempitem.misc6 = 0;
8384 93 tempitem.misc7 = 0;
8385 93 tempitem.misc8 = 0;
8386 93 tempitem.misc9 = 0;
8387 93 tempitem.misc10 = 0;
8388 93 tempitem.wpn3 = 0;
8389 93 tempitem.wpn4 = 0;
8390 93 tempitem.wpn5 = 0;
8391 93 tempitem.wpn6 = 0;
8392 93 tempitem.wpn7 = 0;
8393 93 tempitem.wpn8 = 0;
8394 93 tempitem.wpn9 = 0;
8395 93 tempitem.wpn10 = 0;
8396 93 break;
8397 }
8398 case itype_divinefire:
8399 {
8400 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8401 92 tempitem.misc3 = 0;
8402 92 tempitem.misc4 = 0;
8403 92 tempitem.misc5 = 0;
8404 92 tempitem.misc6 = 0;
8405 92 tempitem.misc7 = 0;
8406 92 tempitem.misc8 = 0;
8407 92 tempitem.misc9 = 0;
8408 92 tempitem.misc10 = 0;
8409 92 tempitem.wpn6 = 0;
8410 92 tempitem.wpn7 = 0;
8411 92 tempitem.wpn8 = 0;
8412 92 tempitem.wpn9 = 0;
8413 92 tempitem.wpn10 = 0;
8414 92 break;
8415 }
8416 case itype_divineescape:
8417 {
8418 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8419 92 tempitem.misc2 = 0;
8420 92 tempitem.misc3 = 0;
8421 92 tempitem.misc4 = 0;
8422 92 tempitem.misc5 = 0;
8423 92 tempitem.misc6 = 0;
8424 92 tempitem.misc7 = 0;
8425 92 tempitem.misc8 = 0;
8426 92 tempitem.misc9 = 0;
8427 92 tempitem.misc10 = 0;
8428 92 tempitem.wpn = 0;
8429 92 tempitem.wpn2 = 0;
8430 92 tempitem.wpn3 = 0;
8431 92 tempitem.wpn4 = 0;
8432 92 tempitem.wpn5 = 0;
8433 92 tempitem.wpn6 = 0;
8434 92 tempitem.wpn7 = 0;
8435 92 tempitem.wpn8 = 0;
8436 92 tempitem.wpn9 = 0;
8437 92 tempitem.wpn10 = 0;
8438 92 break;
8439 }
8440 case itype_divineprotection:
8441 {
8442 92 tempitem.flags &= ~ (ITEM_FLAG5);
8443 92 tempitem.misc2 = 0;
8444 92 tempitem.misc3 = 0;
8445 92 tempitem.misc4 = 0;
8446 92 tempitem.misc5 = 0;
8447 92 tempitem.misc6 = 0;
8448 92 tempitem.misc7 = 0;
8449 92 tempitem.misc8 = 0;
8450 92 tempitem.misc9 = 0;
8451 92 tempitem.misc10 = 0;
8452 92 break;
8453 }
8454 case itype_bomb:
8455 {
8456 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8457 107 tempitem.misc4 = 0;
8458 107 tempitem.misc5 = 0;
8459 107 tempitem.misc6 = 0;
8460 107 tempitem.misc7 = 0;
8461 107 tempitem.misc8 = 0;
8462 107 tempitem.misc9 = 0;
8463 107 tempitem.misc10 = 0;
8464 107 tempitem.wpn3 = 0;
8465 107 tempitem.wpn4 = 0;
8466 107 tempitem.wpn5 = 0;
8467 107 tempitem.wpn6 = 0;
8468 107 tempitem.wpn7 = 0;
8469 107 tempitem.wpn8 = 0;
8470 107 tempitem.wpn9 = 0;
8471 107 tempitem.wpn10 = 0;
8472 107 break;
8473 }
8474 case itype_sbomb:
8475 {
8476 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8477 92 tempitem.misc4 = 0;
8478 92 tempitem.misc5 = 0;
8479 92 tempitem.misc6 = 0;
8480 92 tempitem.misc7 = 0;
8481 92 tempitem.misc8 = 0;
8482 92 tempitem.misc9 = 0;
8483 92 tempitem.misc10 = 0;
8484 92 tempitem.wpn3 = 0;
8485 92 tempitem.wpn4 = 0;
8486 92 tempitem.wpn5 = 0;
8487 92 tempitem.wpn6 = 0;
8488 92 tempitem.wpn7 = 0;
8489 92 tempitem.wpn8 = 0;
8490 92 tempitem.wpn9 = 0;
8491 92 tempitem.wpn10 = 0;
8492 92 break;
8493 }
8494 case itype_clock:
8495 {
8496 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8497 93 tempitem.misc2 = 0;
8498 93 tempitem.misc3 = 0;
8499 93 tempitem.misc4 = 0;
8500 93 tempitem.misc5 = 0;
8501 93 tempitem.misc6 = 0;
8502 93 tempitem.misc7 = 0;
8503 93 tempitem.misc8 = 0;
8504 93 tempitem.misc9 = 0;
8505 93 tempitem.misc10 = 0;
8506 93 tempitem.wpn = 0;
8507 93 tempitem.wpn2 = 0;
8508 93 tempitem.wpn3 = 0;
8509 93 tempitem.wpn4 = 0;
8510 93 tempitem.wpn5 = 0;
8511 93 tempitem.wpn6 = 0;
8512 93 tempitem.wpn7 = 0;
8513 93 tempitem.wpn8 = 0;
8514 93 tempitem.wpn9 = 0;
8515 93 tempitem.wpn10 = 0;
8516 93 break;
8517 }
8518 case itype_key:
8519 {
8520 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8521 92 tempitem.misc1 = 0;
8522 92 tempitem.misc2 = 0;
8523 92 tempitem.misc3 = 0;
8524 92 tempitem.misc4 = 0;
8525 92 tempitem.misc5 = 0;
8526 92 tempitem.misc6 = 0;
8527 92 tempitem.misc7 = 0;
8528 92 tempitem.misc8 = 0;
8529 92 tempitem.misc9 = 0;
8530 92 tempitem.misc10 = 0;
8531 92 tempitem.wpn = 0;
8532 92 tempitem.wpn2 = 0;
8533 92 tempitem.wpn3 = 0;
8534 92 tempitem.wpn4 = 0;
8535 92 tempitem.wpn5 = 0;
8536 92 tempitem.wpn6 = 0;
8537 92 tempitem.wpn7 = 0;
8538 92 tempitem.wpn8 = 0;
8539 92 tempitem.wpn9 = 0;
8540 92 tempitem.wpn10 = 0;
8541 92 break;
8542 }
8543 case itype_magiccontainer:
8544 {
8545 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8546 93 tempitem.misc1 = 0;
8547 93 tempitem.misc2 = 0;
8548 93 tempitem.misc3 = 0;
8549 93 tempitem.misc4 = 0;
8550 93 tempitem.misc5 = 0;
8551 93 tempitem.misc6 = 0;
8552 93 tempitem.misc7 = 0;
8553 93 tempitem.misc8 = 0;
8554 93 tempitem.misc9 = 0;
8555 93 tempitem.misc10 = 0;
8556 93 tempitem.wpn = 0;
8557 93 tempitem.wpn2 = 0;
8558 93 tempitem.wpn3 = 0;
8559 93 tempitem.wpn4 = 0;
8560 93 tempitem.wpn5 = 0;
8561 93 tempitem.wpn6 = 0;
8562 93 tempitem.wpn7 = 0;
8563 93 tempitem.wpn8 = 0;
8564 93 tempitem.wpn9 = 0;
8565 93 tempitem.wpn10 = 0;
8566 93 break;
8567 }
8568 case itype_triforcepiece:
8569 {
8570 184 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8571 184 tempitem.misc3 = 0;
8572 184 tempitem.misc4 = 0;
8573 184 tempitem.misc5 = 0;
8574 184 tempitem.misc6 = 0;
8575 184 tempitem.misc7 = 0;
8576 184 tempitem.misc8 = 0;
8577 184 tempitem.misc9 = 0;
8578 184 tempitem.misc10 = 0;
8579 184 tempitem.wpn = 0;
8580 184 tempitem.wpn2 = 0;
8581 184 tempitem.wpn3 = 0;
8582 184 tempitem.wpn4 = 0;
8583 184 tempitem.wpn5 = 0;
8584 184 tempitem.wpn6 = 0;
8585 184 tempitem.wpn7 = 0;
8586 184 tempitem.wpn8 = 0;
8587 184 tempitem.wpn9 = 0;
8588 184 tempitem.wpn10 = 0;
8589 184 break;
8590 }
8591 case itype_map: case itype_compass: case itype_bosskey:
8592 {
8593 277 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8594 277 tempitem.misc1 = 0;
8595 277 tempitem.misc2 = 0;
8596 277 tempitem.misc3 = 0;
8597 277 tempitem.misc4 = 0;
8598 277 tempitem.misc5 = 0;
8599 277 tempitem.misc6 = 0;
8600 277 tempitem.misc7 = 0;
8601 277 tempitem.misc8 = 0;
8602 277 tempitem.misc9 = 0;
8603 277 tempitem.misc10 = 0;
8604 277 tempitem.wpn = 0;
8605 277 tempitem.wpn2 = 0;
8606 277 tempitem.wpn3 = 0;
8607 277 tempitem.wpn4 = 0;
8608 277 tempitem.wpn5 = 0;
8609 277 tempitem.wpn6 = 0;
8610 277 tempitem.wpn7 = 0;
8611 277 tempitem.wpn8 = 0;
8612 277 tempitem.wpn9 = 0;
8613 277 tempitem.wpn10 = 0;
8614 277 break;
8615 }
8616 case itype_quiver:
8617 {
8618 368 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8619 368 tempitem.misc3 = 0;
8620 368 tempitem.misc4 = 0;
8621 368 tempitem.misc5 = 0;
8622 368 tempitem.misc6 = 0;
8623 368 tempitem.misc7 = 0;
8624 368 tempitem.misc8 = 0;
8625 368 tempitem.misc9 = 0;
8626 368 tempitem.misc10 = 0;
8627 368 tempitem.wpn = 0;
8628 368 tempitem.wpn2 = 0;
8629 368 tempitem.wpn3 = 0;
8630 368 tempitem.wpn4 = 0;
8631 368 tempitem.wpn5 = 0;
8632 368 tempitem.wpn6 = 0;
8633 368 tempitem.wpn7 = 0;
8634 368 tempitem.wpn8 = 0;
8635 368 tempitem.wpn9 = 0;
8636 368 tempitem.wpn10 = 0;
8637 368 break;
8638 }
8639 case itype_lkey:
8640 {
8641 94 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8642 94 tempitem.misc1 = 0;
8643 94 tempitem.misc2 = 0;
8644 94 tempitem.misc3 = 0;
8645 94 tempitem.misc4 = 0;
8646 94 tempitem.misc5 = 0;
8647 94 tempitem.misc6 = 0;
8648 94 tempitem.misc7 = 0;
8649 94 tempitem.misc8 = 0;
8650 94 tempitem.misc9 = 0;
8651 94 tempitem.misc10 = 0;
8652 94 tempitem.wpn = 0;
8653 94 tempitem.wpn2 = 0;
8654 94 tempitem.wpn3 = 0;
8655 94 tempitem.wpn4 = 0;
8656 94 tempitem.wpn5 = 0;
8657 94 tempitem.wpn6 = 0;
8658 94 tempitem.wpn7 = 0;
8659 94 tempitem.wpn8 = 0;
8660 94 tempitem.wpn9 = 0;
8661 94 tempitem.wpn10 = 0;
8662 94 break;
8663 }
8664 case itype_cbyrna:
8665 {
8666 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8667 92 tempitem.misc4 = 0;
8668 92 tempitem.misc5 = 0;
8669 92 tempitem.misc6 = 0;
8670 92 tempitem.misc7 = 0;
8671 92 tempitem.misc8 = 0;
8672 92 tempitem.misc9 = 0;
8673 92 tempitem.misc10 = 0;
8674 92 tempitem.wpn6 = 0;
8675 92 tempitem.wpn7 = 0;
8676 92 tempitem.wpn8 = 0;
8677 92 tempitem.wpn9 = 0;
8678 92 tempitem.wpn10 = 0;
8679 92 break;
8680 }
8681 case itype_rupee: case itype_arrowammo:
8682 {
8683 1135 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8684 1135 tempitem.misc1 = 0;
8685 1135 tempitem.misc2 = 0;
8686 1135 tempitem.misc3 = 0;
8687 1135 tempitem.misc4 = 0;
8688 1135 tempitem.misc5 = 0;
8689 1135 tempitem.misc6 = 0;
8690 1135 tempitem.misc7 = 0;
8691 1135 tempitem.misc8 = 0;
8692 1135 tempitem.misc9 = 0;
8693 1135 tempitem.misc10 = 0;
8694 1135 tempitem.wpn = 0;
8695 1135 tempitem.wpn2 = 0;
8696 1135 tempitem.wpn3 = 0;
8697 1135 tempitem.wpn4 = 0;
8698 1135 tempitem.wpn5 = 0;
8699 1135 tempitem.wpn6 = 0;
8700 1135 tempitem.wpn7 = 0;
8701 1135 tempitem.wpn8 = 0;
8702 1135 tempitem.wpn9 = 0;
8703 1135 tempitem.wpn10 = 0;
8704 1135 break;
8705 }
8706 case itype_fairy:
8707 {
8708 168 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8709 168 tempitem.misc4 = 0;
8710 168 tempitem.misc5 = 0;
8711 168 tempitem.misc6 = 0;
8712 168 tempitem.misc7 = 0;
8713 168 tempitem.misc8 = 0;
8714 168 tempitem.misc9 = 0;
8715 168 tempitem.misc10 = 0;
8716 168 tempitem.wpn = 0;
8717 168 tempitem.wpn2 = 0;
8718 168 tempitem.wpn3 = 0;
8719 168 tempitem.wpn4 = 0;
8720 168 tempitem.wpn5 = 0;
8721 168 tempitem.wpn6 = 0;
8722 168 tempitem.wpn7 = 0;
8723 168 tempitem.wpn8 = 0;
8724 168 tempitem.wpn9 = 0;
8725 168 tempitem.wpn10 = 0;
8726 168 break;
8727 }
8728 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8729 {
8730 983 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8731 983 tempitem.misc1 = 0;
8732 983 tempitem.misc2 = 0;
8733 983 tempitem.misc3 = 0;
8734 983 tempitem.misc4 = 0;
8735 983 tempitem.misc5 = 0;
8736 983 tempitem.misc6 = 0;
8737 983 tempitem.misc7 = 0;
8738 983 tempitem.misc8 = 0;
8739 983 tempitem.misc9 = 0;
8740 983 tempitem.misc10 = 0;
8741 983 tempitem.wpn = 0;
8742 983 tempitem.wpn2 = 0;
8743 983 tempitem.wpn3 = 0;
8744 983 tempitem.wpn4 = 0;
8745 983 tempitem.wpn5 = 0;
8746 983 tempitem.wpn6 = 0;
8747 983 tempitem.wpn7 = 0;
8748 983 tempitem.wpn8 = 0;
8749 983 tempitem.wpn9 = 0;
8750 983 tempitem.wpn10 = 0;
8751 983 break;
8752 }
8753 case itype_bombbag:
8754 {
8755 368 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8756 368 tempitem.misc3 = 0;
8757 368 tempitem.misc4 = 0;
8758 368 tempitem.misc5 = 0;
8759 368 tempitem.misc6 = 0;
8760 368 tempitem.misc7 = 0;
8761 368 tempitem.misc8 = 0;
8762 368 tempitem.misc9 = 0;
8763 368 tempitem.misc10 = 0;
8764 368 tempitem.wpn = 0;
8765 368 tempitem.wpn2 = 0;
8766 368 tempitem.wpn3 = 0;
8767 368 tempitem.wpn4 = 0;
8768 368 tempitem.wpn5 = 0;
8769 368 tempitem.wpn6 = 0;
8770 368 tempitem.wpn7 = 0;
8771 368 tempitem.wpn8 = 0;
8772 368 tempitem.wpn9 = 0;
8773 368 tempitem.wpn10 = 0;
8774 368 break;
8775 }
8776 case itype_rocs:
8777 {
8778 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8779 92 tempitem.misc1 = 0;
8780 92 tempitem.misc2 = 0;
8781 92 tempitem.misc3 = 0;
8782 92 tempitem.misc4 = 0;
8783 92 tempitem.misc5 = 0;
8784 92 tempitem.misc6 = 0;
8785 92 tempitem.misc7 = 0;
8786 92 tempitem.misc8 = 0;
8787 92 tempitem.misc9 = 0;
8788 92 tempitem.misc10 = 0;
8789 92 tempitem.wpn = 0;
8790 92 tempitem.wpn2 = 0;
8791 92 tempitem.wpn3 = 0;
8792 92 tempitem.wpn4 = 0;
8793 92 tempitem.wpn5 = 0;
8794 92 tempitem.wpn6 = 0;
8795 92 tempitem.wpn7 = 0;
8796 92 tempitem.wpn8 = 0;
8797 92 tempitem.wpn9 = 0;
8798 92 tempitem.wpn10 = 0;
8799 92 break;
8800 }
8801 case itype_hoverboots:
8802 {
8803 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8804 92 tempitem.misc2 = 0;
8805 92 tempitem.misc3 = 0;
8806 92 tempitem.misc4 = 0;
8807 92 tempitem.misc5 = 0;
8808 92 tempitem.misc6 = 0;
8809 92 tempitem.misc7 = 0;
8810 92 tempitem.misc8 = 0;
8811 92 tempitem.misc9 = 0;
8812 92 tempitem.misc10 = 0;
8813 92 tempitem.wpn2 = 0;
8814 92 tempitem.wpn3 = 0;
8815 92 tempitem.wpn4 = 0;
8816 92 tempitem.wpn5 = 0;
8817 92 tempitem.wpn6 = 0;
8818 92 tempitem.wpn7 = 0;
8819 92 tempitem.wpn8 = 0;
8820 92 tempitem.wpn9 = 0;
8821 92 tempitem.wpn10 = 0;
8822 92 break;
8823 }
8824 case itype_spinscroll:
8825 {
8826 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8827 92 tempitem.misc2 = 0;
8828 92 tempitem.misc3 = 0;
8829 92 tempitem.misc4 = 0;
8830 92 tempitem.misc5 = 0;
8831 92 tempitem.misc6 = 0;
8832 92 tempitem.misc7 = 0;
8833 92 tempitem.misc8 = 0;
8834 92 tempitem.misc9 = 0;
8835 92 tempitem.misc10 = 0;
8836 92 tempitem.wpn = 0;
8837 92 tempitem.wpn2 = 0;
8838 92 tempitem.wpn3 = 0;
8839 92 tempitem.wpn4 = 0;
8840 92 tempitem.wpn5 = 0;
8841 92 tempitem.wpn6 = 0;
8842 92 tempitem.wpn7 = 0;
8843 92 tempitem.wpn8 = 0;
8844 92 tempitem.wpn9 = 0;
8845 92 tempitem.wpn10 = 0;
8846 92 break;
8847 }
8848 case itype_crossscroll:
8849 {
8850 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8851 92 tempitem.misc1 = 0;
8852 92 tempitem.misc2 = 0;
8853 92 tempitem.misc3 = 0;
8854 92 tempitem.misc4 = 0;
8855 92 tempitem.misc5 = 0;
8856 92 tempitem.misc6 = 0;
8857 92 tempitem.misc7 = 0;
8858 92 tempitem.misc8 = 0;
8859 92 tempitem.misc9 = 0;
8860 92 tempitem.misc10 = 0;
8861 92 tempitem.wpn = 0;
8862 92 tempitem.wpn2 = 0;
8863 92 tempitem.wpn3 = 0;
8864 92 tempitem.wpn4 = 0;
8865 92 tempitem.wpn5 = 0;
8866 92 tempitem.wpn6 = 0;
8867 92 tempitem.wpn7 = 0;
8868 92 tempitem.wpn8 = 0;
8869 92 tempitem.wpn9 = 0;
8870 92 tempitem.wpn10 = 0;
8871 92 break;
8872 }
8873 case itype_quakescroll:
8874 {
8875 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8876 92 tempitem.misc3 = 0;
8877 92 tempitem.misc4 = 0;
8878 92 tempitem.misc5 = 0;
8879 92 tempitem.misc6 = 0;
8880 92 tempitem.misc7 = 0;
8881 92 tempitem.misc8 = 0;
8882 92 tempitem.misc9 = 0;
8883 92 tempitem.misc10 = 0;
8884 92 tempitem.wpn = 0;
8885 92 tempitem.wpn2 = 0;
8886 92 tempitem.wpn3 = 0;
8887 92 tempitem.wpn4 = 0;
8888 92 tempitem.wpn5 = 0;
8889 92 tempitem.wpn6 = 0;
8890 92 tempitem.wpn7 = 0;
8891 92 tempitem.wpn8 = 0;
8892 92 tempitem.wpn9 = 0;
8893 92 tempitem.wpn10 = 0;
8894 92 break;
8895 }
8896 case itype_whispring:
8897 {
8898 185 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8899 185 tempitem.misc2 = 0;
8900 185 tempitem.misc3 = 0;
8901 185 tempitem.misc4 = 0;
8902 185 tempitem.misc5 = 0;
8903 185 tempitem.misc6 = 0;
8904 185 tempitem.misc7 = 0;
8905 185 tempitem.misc8 = 0;
8906 185 tempitem.misc9 = 0;
8907 185 tempitem.misc10 = 0;
8908 185 tempitem.wpn = 0;
8909 185 tempitem.wpn2 = 0;
8910 185 tempitem.wpn3 = 0;
8911 185 tempitem.wpn4 = 0;
8912 185 tempitem.wpn5 = 0;
8913 185 tempitem.wpn6 = 0;
8914 185 tempitem.wpn7 = 0;
8915 185 tempitem.wpn8 = 0;
8916 185 tempitem.wpn9 = 0;
8917 185 tempitem.wpn10 = 0;
8918 185 break;
8919 }
8920 case itype_chargering:
8921 {
8922 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8923 184 tempitem.misc3 = 0;
8924 184 tempitem.misc4 = 0;
8925 184 tempitem.misc5 = 0;
8926 184 tempitem.misc6 = 0;
8927 184 tempitem.misc7 = 0;
8928 184 tempitem.misc8 = 0;
8929 184 tempitem.misc9 = 0;
8930 184 tempitem.misc10 = 0;
8931 184 tempitem.wpn = 0;
8932 184 tempitem.wpn2 = 0;
8933 184 tempitem.wpn3 = 0;
8934 184 tempitem.wpn4 = 0;
8935 184 tempitem.wpn5 = 0;
8936 184 tempitem.wpn6 = 0;
8937 184 tempitem.wpn7 = 0;
8938 184 tempitem.wpn8 = 0;
8939 184 tempitem.wpn9 = 0;
8940 184 tempitem.wpn10 = 0;
8941 184 break;
8942 }
8943 case itype_perilscroll:
8944 {
8945 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8946 92 tempitem.misc2 = 0;
8947 92 tempitem.misc3 = 0;
8948 92 tempitem.misc4 = 0;
8949 92 tempitem.misc5 = 0;
8950 92 tempitem.misc6 = 0;
8951 92 tempitem.misc7 = 0;
8952 92 tempitem.misc8 = 0;
8953 92 tempitem.misc9 = 0;
8954 92 tempitem.misc10 = 0;
8955 92 tempitem.wpn = 0;
8956 92 tempitem.wpn2 = 0;
8957 92 tempitem.wpn3 = 0;
8958 92 tempitem.wpn4 = 0;
8959 92 tempitem.wpn5 = 0;
8960 92 tempitem.wpn6 = 0;
8961 92 tempitem.wpn7 = 0;
8962 92 tempitem.wpn8 = 0;
8963 92 tempitem.wpn9 = 0;
8964 92 tempitem.wpn10 = 0;
8965 92 break;
8966 }
8967 case itype_wealthmedal:
8968 {
8969 277 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8970 277 tempitem.misc2 = 0;
8971 277 tempitem.misc3 = 0;
8972 277 tempitem.misc4 = 0;
8973 277 tempitem.misc5 = 0;
8974 277 tempitem.misc6 = 0;
8975 277 tempitem.misc7 = 0;
8976 277 tempitem.misc8 = 0;
8977 277 tempitem.misc9 = 0;
8978 277 tempitem.misc10 = 0;
8979 277 tempitem.wpn = 0;
8980 277 tempitem.wpn2 = 0;
8981 277 tempitem.wpn3 = 0;
8982 277 tempitem.wpn4 = 0;
8983 277 tempitem.wpn5 = 0;
8984 277 tempitem.wpn6 = 0;
8985 277 tempitem.wpn7 = 0;
8986 277 tempitem.wpn8 = 0;
8987 277 tempitem.wpn9 = 0;
8988 277 tempitem.wpn10 = 0;
8989 277 break;
8990 }
8991 case itype_heartring:
8992 {
8993 278 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8994 278 tempitem.misc3 = 0;
8995 278 tempitem.misc4 = 0;
8996 278 tempitem.misc5 = 0;
8997 278 tempitem.misc6 = 0;
8998 278 tempitem.misc7 = 0;
8999 278 tempitem.misc8 = 0;
9000 278 tempitem.misc9 = 0;
9001 278 tempitem.misc10 = 0;
9002 278 tempitem.wpn = 0;
9003 278 tempitem.wpn2 = 0;
9004 278 tempitem.wpn3 = 0;
9005 278 tempitem.wpn4 = 0;
9006 278 tempitem.wpn5 = 0;
9007 278 tempitem.wpn6 = 0;
9008 278 tempitem.wpn7 = 0;
9009 278 tempitem.wpn8 = 0;
9010 278 tempitem.wpn9 = 0;
9011 278 tempitem.wpn10 = 0;
9012 278 break;
9013 }
9014 case itype_magicring:
9015 {
9016 372 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9017 372 tempitem.misc3 = 0;
9018 372 tempitem.misc4 = 0;
9019 372 tempitem.misc5 = 0;
9020 372 tempitem.misc6 = 0;
9021 372 tempitem.misc7 = 0;
9022 372 tempitem.misc8 = 0;
9023 372 tempitem.misc9 = 0;
9024 372 tempitem.misc10 = 0;
9025 372 tempitem.wpn = 0;
9026 372 tempitem.wpn2 = 0;
9027 372 tempitem.wpn3 = 0;
9028 372 tempitem.wpn4 = 0;
9029 372 tempitem.wpn5 = 0;
9030 372 tempitem.wpn6 = 0;
9031 372 tempitem.wpn7 = 0;
9032 372 tempitem.wpn8 = 0;
9033 372 tempitem.wpn9 = 0;
9034 372 tempitem.wpn10 = 0;
9035 372 break;
9036 }
9037 case itype_spinscroll2:
9038 {
9039 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9040 92 tempitem.misc2 = 0;
9041 92 tempitem.misc3 = 0;
9042 92 tempitem.misc4 = 0;
9043 92 tempitem.misc5 = 0;
9044 92 tempitem.misc6 = 0;
9045 92 tempitem.misc7 = 0;
9046 92 tempitem.misc8 = 0;
9047 92 tempitem.misc9 = 0;
9048 92 tempitem.misc10 = 0;
9049 92 tempitem.wpn = 0;
9050 92 tempitem.wpn2 = 0;
9051 92 tempitem.wpn3 = 0;
9052 92 tempitem.wpn4 = 0;
9053 92 tempitem.wpn5 = 0;
9054 92 tempitem.wpn6 = 0;
9055 92 tempitem.wpn7 = 0;
9056 92 tempitem.wpn8 = 0;
9057 92 tempitem.wpn9 = 0;
9058 92 tempitem.wpn10 = 0;
9059 92 break;
9060 }
9061 case itype_quakescroll2:
9062 {
9063 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9064 92 tempitem.misc3 = 0;
9065 92 tempitem.misc4 = 0;
9066 92 tempitem.misc5 = 0;
9067 92 tempitem.misc6 = 0;
9068 92 tempitem.misc7 = 0;
9069 92 tempitem.misc8 = 0;
9070 92 tempitem.misc9 = 0;
9071 92 tempitem.misc10 = 0;
9072 92 tempitem.wpn = 0;
9073 92 tempitem.wpn2 = 0;
9074 92 tempitem.wpn3 = 0;
9075 92 tempitem.wpn4 = 0;
9076 92 tempitem.wpn5 = 0;
9077 92 tempitem.wpn6 = 0;
9078 92 tempitem.wpn7 = 0;
9079 92 tempitem.wpn8 = 0;
9080 92 tempitem.wpn9 = 0;
9081 92 tempitem.wpn10 = 0;
9082 92 break;
9083 }
9084 case itype_agony:
9085 {
9086 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9087 92 tempitem.misc2 = 0;
9088 92 tempitem.misc3 = 0;
9089 92 tempitem.misc4 = 0;
9090 92 tempitem.misc5 = 0;
9091 92 tempitem.misc6 = 0;
9092 92 tempitem.misc7 = 0;
9093 92 tempitem.misc8 = 0;
9094 92 tempitem.misc9 = 0;
9095 92 tempitem.misc10 = 0;
9096 92 tempitem.wpn = 0;
9097 92 tempitem.wpn2 = 0;
9098 92 tempitem.wpn3 = 0;
9099 92 tempitem.wpn4 = 0;
9100 92 tempitem.wpn5 = 0;
9101 92 tempitem.wpn6 = 0;
9102 92 tempitem.wpn7 = 0;
9103 92 tempitem.wpn8 = 0;
9104 92 tempitem.wpn9 = 0;
9105 92 tempitem.wpn10 = 0;
9106 92 break;
9107 }
9108 case itype_stompboots:
9109 {
9110 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9111 92 tempitem.misc1 = 0;
9112 92 tempitem.misc2 = 0;
9113 92 tempitem.misc3 = 0;
9114 92 tempitem.misc4 = 0;
9115 92 tempitem.misc5 = 0;
9116 92 tempitem.misc6 = 0;
9117 92 tempitem.misc7 = 0;
9118 92 tempitem.misc8 = 0;
9119 92 tempitem.misc9 = 0;
9120 92 tempitem.misc10 = 0;
9121 92 tempitem.wpn = 0;
9122 92 tempitem.wpn2 = 0;
9123 92 tempitem.wpn3 = 0;
9124 92 tempitem.wpn4 = 0;
9125 92 tempitem.wpn5 = 0;
9126 92 tempitem.wpn6 = 0;
9127 92 tempitem.wpn7 = 0;
9128 92 tempitem.wpn8 = 0;
9129 92 tempitem.wpn9 = 0;
9130 92 tempitem.wpn10 = 0;
9131 92 break;
9132 }
9133 case itype_whimsicalring:
9134 {
9135 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9136 92 tempitem.misc2 = 0;
9137 92 tempitem.misc3 = 0;
9138 92 tempitem.misc4 = 0;
9139 92 tempitem.misc5 = 0;
9140 92 tempitem.misc6 = 0;
9141 92 tempitem.misc7 = 0;
9142 92 tempitem.misc8 = 0;
9143 92 tempitem.misc9 = 0;
9144 92 tempitem.misc10 = 0;
9145 92 tempitem.wpn = 0;
9146 92 tempitem.wpn2 = 0;
9147 92 tempitem.wpn3 = 0;
9148 92 tempitem.wpn4 = 0;
9149 92 tempitem.wpn5 = 0;
9150 92 tempitem.wpn6 = 0;
9151 92 tempitem.wpn7 = 0;
9152 92 tempitem.wpn8 = 0;
9153 92 tempitem.wpn9 = 0;
9154 92 tempitem.wpn10 = 0;
9155 92 break;
9156 }
9157 case itype_perilring:
9158 {
9159 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9160 93 tempitem.misc2 = 0;
9161 93 tempitem.misc3 = 0;
9162 93 tempitem.misc4 = 0;
9163 93 tempitem.misc5 = 0;
9164 93 tempitem.misc6 = 0;
9165 93 tempitem.misc7 = 0;
9166 93 tempitem.misc8 = 0;
9167 93 tempitem.misc9 = 0;
9168 93 tempitem.misc10 = 0;
9169 93 tempitem.wpn = 0;
9170 93 tempitem.wpn2 = 0;
9171 93 tempitem.wpn3 = 0;
9172 93 tempitem.wpn4 = 0;
9173 93 tempitem.wpn5 = 0;
9174 93 tempitem.wpn6 = 0;
9175 93 tempitem.wpn7 = 0;
9176 93 tempitem.wpn8 = 0;
9177 93 tempitem.wpn9 = 0;
9178 93 tempitem.wpn10 = 0;
9179 93 break;
9180 }
9181 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9182 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9183 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9184 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9185 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9186 {
9187 2541 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9188 2541 tempitem.misc1 = 0;
9189 2541 tempitem.misc2 = 0;
9190 2541 tempitem.misc3 = 0;
9191 2541 tempitem.misc4 = 0;
9192 2541 tempitem.misc5 = 0;
9193 2541 tempitem.misc6 = 0;
9194 2541 tempitem.misc7 = 0;
9195 2541 tempitem.misc8 = 0;
9196 2541 tempitem.misc9 = 0;
9197 2541 tempitem.misc10 = 0;
9198 2541 tempitem.wpn = 0;
9199 2541 tempitem.wpn2 = 0;
9200 2541 tempitem.wpn3 = 0;
9201 2541 tempitem.wpn4 = 0;
9202 2541 tempitem.wpn5 = 0;
9203 2541 tempitem.wpn6 = 0;
9204 2541 tempitem.wpn7 = 0;
9205 2541 tempitem.wpn8 = 0;
9206 2541 tempitem.wpn9 = 0;
9207 2541 tempitem.wpn10 = 0;
9208 2541 break;
9209 }
9210 }
9211 23808 }
9212 //Port quest rules to items
9213
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( s_version <= 31)
9214 {
9215
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23701 times.
23808 if(tempitem.family == itype_bomb)
9216 {
9217
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 90 times.
107 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9218 90 else tempitem.flags &= ~ ITEM_FLAG2;
9219 107 }
9220
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23609 times.
23701 else if(tempitem.family == itype_sbomb)
9221 {
9222
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 75 times.
92 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9223 75 else tempitem.flags &= ~ ITEM_FLAG2;
9224 92 }
9225
9226
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 23332 times.
23609 else if(tempitem.family == itype_brang)
9227 {
9228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 277 times.
277 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9229 277 else tempitem.flags &= ~ ITEM_FLAG4;
9230 277 }
9231
2/2
✓ Branch 0 taken 23225 times.
✓ Branch 1 taken 107 times.
23332 else if(tempitem.family == itype_wand)
9232 {
9233
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 105 times.
107 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9234 105 else tempitem.flags &= ~ ITEM_FLAG3;
9235 107 }
9236 23808 }
9237
9238 //Port quest rules to items
9239
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( s_version <= 37)
9240 {
9241
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 23715 times.
23808 if(tempitem.family == itype_flippers)
9242 {
9243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9244 93 else tempitem.flags &= ~ ITEM_FLAG1;
9245 93 }
9246
2/2
✓ Branch 0 taken 15904 times.
✓ Branch 1 taken 7811 times.
23715 else if(tempitem.family == itype_sword)
9247 {
9248
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9249 7742 else tempitem.flags &= ~ ITEM_FLAG5;
9250 7811 }
9251
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 15797 times.
15904 else if(tempitem.family == itype_wand)
9252 {
9253
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 104 times.
107 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9254 104 else tempitem.flags &= ~ ITEM_FLAG5;
9255 107 }
9256
4/4
✓ Branch 0 taken 15690 times.
✓ Branch 1 taken 107 times.
✓ Branch 2 taken 222 times.
✓ Branch 3 taken 15468 times.
15797 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9257 {
9258 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9259
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 257 times.
329 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9260 257 else tempitem.flags &= ~ ITEM_FLAG3;
9261 329 }
9262 23808 }
9263
9264
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( s_version < 38)
9265 {
9266
4/4
✓ Branch 0 taken 23531 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 23347 times.
23808 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9267 {
9268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9269 461 else tempitem.flags &= ~ITEM_FLAG4;
9270
9271
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 450 times.
461 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9272 450 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9273 461 }
9274
2/2
✓ Branch 0 taken 23073 times.
✓ Branch 1 taken 274 times.
23347 else if(tempitem.family == itype_arrow)
9275 {
9276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274 times.
274 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9277 274 else tempitem.flags &= ~ITEM_FLAG4;
9278
9279
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 270 times.
274 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9280 270 else tempitem.flags |= ITEM_FLAG2;
9281 274 }
9282 23808 }
9283
9284
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( s_version < 39)
9285 {
9286
6/6
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 23609 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 222 times.
✓ Branch 5 taken 23387 times.
23808 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9287 {
9288
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 409 times.
421 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9289 409 else tempitem.flags &= ~ITEM_FLAG5;
9290 421 }
9291
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 23204 times.
23387 else if(tempitem.family == itype_potion)
9292 {
9293
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 159 times.
183 if(get_qr(qr_NONBUBBLEMEDICINE))
9294 {
9295 24 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9296 24 }
9297 else
9298 {
9299 159 tempitem.flags |= ITEM_FLAG3;
9300
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 74 times.
159 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9301 74 else tempitem.flags &= ~ITEM_FLAG4;
9302 }
9303 183 }
9304
2/2
✓ Branch 0 taken 23020 times.
✓ Branch 1 taken 184 times.
23204 else if(tempitem.family == itype_triforcepiece)
9305 {
9306
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 154 times.
184 if(get_qr(qr_NONBUBBLETRIFORCE))
9307 {
9308 30 tempitem.flags |= ITEM_FLAG3;
9309
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 24 times.
30 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9310 24 else tempitem.flags &= ~ITEM_FLAG4;
9311 30 }
9312 else
9313 {
9314 154 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9315 }
9316 184 }
9317 23808 }
9318
9319
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( s_version < 40)
9320 {
9321
4/4
✓ Branch 0 taken 23506 times.
✓ Branch 1 taken 302 times.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 23413 times.
23808 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9322 {
9323
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 348 times.
395 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9324 348 else tempitem.flags &= ~ITEM_FLAG1;
9325 395 }
9326
8/8
✓ Branch 0 taken 23191 times.
✓ Branch 1 taken 222 times.
✓ Branch 2 taken 15380 times.
✓ Branch 3 taken 7811 times.
✓ Branch 4 taken 15273 times.
✓ Branch 5 taken 107 times.
✓ Branch 6 taken 92 times.
✓ Branch 7 taken 15181 times.
23413 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9327 {
9328
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 8151 times.
8232 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9329 8151 else tempitem.flags &= ~ITEM_FLAG8;
9330 8232 }
9331
6/6
✓ Branch 0 taken 15997 times.
✓ Branch 1 taken 7811 times.
✓ Branch 2 taken 15890 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 93 times.
✓ Branch 5 taken 15797 times.
23808 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9332 {
9333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8011 times.
8011 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9334 8011 else tempitem.flags &= ~ITEM_FLAG7;
9335 8011 }
9336
2/2
✓ Branch 0 taken 15705 times.
✓ Branch 1 taken 92 times.
15797 else if(tempitem.family == itype_cbyrna)
9337 {
9338 92 tempitem.flags |= ITEM_FLAG7;
9339 92 }
9340 23808 }
9341
9342
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( s_version < 41 )
9343 {
9344
2/2
✓ Branch 0 taken 15997 times.
✓ Branch 1 taken 7811 times.
23808 if(tempitem.family == itype_sword)
9345 {
9346
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9347 7742 else tempitem.flags &= ~ITEM_FLAG9;
9348
9349
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9350 7742 else tempitem.flags &= ~ITEM_FLAG10;
9351 7811 }
9352 23808 }
9353
9354
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( s_version < 42 )
9355 {
9356
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23701 times.
23808 if(tempitem.family == itype_wand)
9357 {
9358
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 105 times.
107 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9359 105 else tempitem.flags &= ~ITEM_FLAG3;
9360
9361 107 tempitem.flags &= ~ITEM_FLAG6;
9362 107 }
9363
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 23608 times.
23701 else if(tempitem.family == itype_hammer)
9364 {
9365 93 tempitem.flags &= ~ITEM_FLAG3;
9366 93 }
9367
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23516 times.
23608 else if(tempitem.family == itype_cbyrna)
9368 {
9369 92 tempitem.flags |= ITEM_FLAG3;
9370
9371 92 tempitem.flags &= ~ITEM_FLAG6;
9372 92 }
9373
2/2
✓ Branch 0 taken 15705 times.
✓ Branch 1 taken 7811 times.
23516 else if(tempitem.family == itype_sword)
9374 {
9375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7811 times.
7811 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9376 7811 else tempitem.flags &= ~ITEM_FLAG6;
9377 7811 }
9378 23808 }
9379
9380
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( s_version < 43 )
9381 {
9382
2/2
✓ Branch 0 taken 23670 times.
✓ Branch 1 taken 138 times.
23808 if(tempitem.family == itype_whistle)
9383 {
9384
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 135 times.
138 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9385 135 else tempitem.flags &= ~ITEM_FLAG3;
9386 138 }
9387 23808 }
9388
9389
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( s_version < 45 )
9390 {
9391
2/2
✓ Branch 0 taken 23715 times.
✓ Branch 1 taken 93 times.
23808 if(tempitem.family == itype_flippers)
9392 {
9393 93 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9394 93 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9395 93 }
9396 23808 }
9397
9398
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( s_version < 46 )
9399 {
9400
2/2
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
23808 if(tempitem.family == itype_raft)
9401 {
9402 92 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9403 92 }
9404 23808 }
9405
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if ( s_version < 34 ) //! set the default counter for older quests.
9406 {
9407
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 23733 times.
23808 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9408 {
9409 75 tempitem.cost_counter[0] = 1;
9410 75 }
9411 else
9412 {
9413
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 19125 times.
23733 if(get_qr(qr_ENABLEMAGIC))
9414 4608 tempitem.cost_counter[0] = 4;
9415 else
9416 {
9417 19125 tempitem.cost_amount[0] = 0;
9418 19125 tempitem.cost_counter[0] = -1;
9419 }
9420 }
9421 23808 }
9422
9423
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if ( s_version < 35 ) //new Lens of Truth flags
9424 {
9425
2/2
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
23808 if ( tempitem.family == itype_lens )
9426 {
9427
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 3 times.
92 if ( get_qr(qr_RAFTLENS) )
9428 {
9429 3 tempitem.flags |= ITEM_FLAG4;
9430 3 }
9431
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 52 times.
92 if ( get_qr(qr_LENSHINTS) )
9432 {
9433 52 tempitem.flags |= ITEM_FLAG1;
9434 52 }
9435
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 4 times.
92 if ( get_qr(qr_LENSSEESENEMIES) )
9436 {
9437 4 tempitem.flags |= ITEM_FLAG5;
9438 4 }
9439 92 }
9440 23808 }
9441
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9442 {
9443
2/2
✓ Branch 0 taken 190464 times.
✓ Branch 1 taken 23808 times.
214272 for ( int32_t q = 0; q < 8; q++ )
9444 {
9445 190464 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9446 190464 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9447 190464 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9448 190464 tempitem.sprite_initiald[q] = 0;
9449 190464 }
9450
2/2
✓ Branch 0 taken 47616 times.
✓ Branch 1 taken 23808 times.
71424 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9451 23808 tempitem.sprite_script = 0;
9452 23808 }
9453
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9454 {
9455 23808 tempitem.pickupflag = 0;
9456 23808 }
9457
9458
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( s_version < 51 )
9459 {
9460
2/2
✓ Branch 0 taken 23586 times.
✓ Branch 1 taken 222 times.
23808 if( tempitem.family == itype_candle )
9461 {
9462 222 tempitem.misc4 = 50; //Step speed
9463 222 }
9464 23808 }
9465
9466
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( s_version < 52 )
9467 {
9468
2/2
✓ Branch 0 taken 23525 times.
✓ Branch 1 taken 283 times.
23808 if( tempitem.family == itype_shield )
9469 283 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9470 23808 }
9471
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if(s_version < 53)
9472 {
9473
4/4
✓ Branch 0 taken 23335 times.
✓ Branch 1 taken 274 times.
✓ Branch 2 taken 107 times.
✓ Branch 3 taken 92 times.
23808 switch(tempitem.family)
9474 {
9475 case itype_arrow:
9476 274 tempitem.cost_counter[1] = crARROWS;
9477 274 tempitem.cost_amount[1] = 1;
9478 274 break;
9479 case itype_bomb:
9480 107 tempitem.cost_counter[1] = crBOMBS;
9481 107 tempitem.cost_amount[1] = 1;
9482 107 break;
9483 case itype_sbomb:
9484 92 tempitem.cost_counter[1] = crSBOMBS;
9485 92 tempitem.cost_amount[1] = 1;
9486 92 break;
9487 default:
9488 23335 tempitem.cost_counter[1] = crNONE;
9489 23335 tempitem.cost_amount[1] = 0;
9490 23335 }
9491 23808 tempitem.magiccosttimer[1] = 0;
9492 23808 }
9493
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 25088 times.
32768 if( s_version < 54 )
9494 {
9495
2/2
✓ Branch 0 taken 24989 times.
✓ Branch 1 taken 99 times.
25088 if( tempitem.family == itype_flippers )
9496 99 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9497 25088 }
9498
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 25088 times.
32768 if(s_version < 55)
9499 {
9500
3/3
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 24700 times.
25088 switch(tempitem.family)
9501 {
9502 case itype_spinscroll:
9503 case itype_quakescroll:
9504 194 tempitem.usesound2 = WAV_ZN1CHARGE;
9505 194 break;
9506 case itype_spinscroll2:
9507 case itype_quakescroll2:
9508 194 tempitem.usesound2 = WAV_ZN1CHARGE2;
9509 194 break;
9510 }
9511 25088 }
9512
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 25088 times.
32768 if(s_version < 56)
9513 {
9514
4/4
✓ Branch 0 taken 24645 times.
✓ Branch 1 taken 97 times.
✓ Branch 2 taken 234 times.
✓ Branch 3 taken 112 times.
25088 switch(tempitem.family)
9515 {
9516 case itype_divinefire:
9517
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 5 times.
97 SETFLAG(tempitem.flags, ITEM_FLAG9, version < 0x255); //Strong Fire
9518
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 81 times.
97 SETFLAG(tempitem.flags, ITEM_FLAG10, version < 0x250); //Magic Fire
9519 97 tempitem.flags |= ITEM_FLAG11; //Divine Fire
9520 97 break;
9521 case itype_candle:
9522
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 120 times.
234 SETFLAG(tempitem.flags, ITEM_FLAG9, tempitem.fam_type > 1); //Strong Fire
9523 234 tempitem.flags &= ~ITEM_FLAG10; //Magic Fire
9524 234 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9525 234 break;
9526 case itype_book:
9527 112 tempitem.flags |= ITEM_FLAG9; //Strong Fire
9528 112 tempitem.flags |= ITEM_FLAG10; //Magic Fire
9529 112 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9530 112 break;
9531 }
9532 25088 }
9533
9534
2/2
✓ Branch 0 taken 30624 times.
✓ Branch 1 taken 2144 times.
32768 if(tempitem.fam_type==0) // Always do this
9535 2144 tempitem.fam_type=1;
9536
9537 32768 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9538 32768 }
9539
9540 128 return 0;
9541 128 }
9542
9543 static bool did_init_def_items = false;
9544 65728 void init_def_items()
9545 {
9546
2/2
✓ Branch 0 taken 65613 times.
✓ Branch 1 taken 115 times.
65728 if(did_init_def_items) return;
9547 115 did_init_def_items = true;
9548 115 default_items[3].cost_counter[1] = crBOMBS;
9549 115 default_items[13].cost_counter[1] = crARROWS;
9550 115 default_items[14].cost_counter[1] = crARROWS;
9551 115 default_items[48].cost_counter[1] = crSBOMBS;
9552 115 default_items[57].cost_counter[1] = crARROWS;
9553 65728 }
9554 65728 void reset_itembuf(itemdata *item, int32_t id)
9555 {
9556 65728 init_def_items();
9557
2/2
✓ Branch 0 taken 28024 times.
✓ Branch 1 taken 37704 times.
65728 if(id<iLast)
9558 {
9559 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9560 37704 word tile = item->tile;
9561 37704 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9562 37704 int32_t ltm = item->ltm;
9563
9564 37704 memcpy(item,&default_items[id],sizeof(itemdata));
9565 37704 item->tile = tile;
9566 37704 item->misc_flags = miscs;
9567 37704 item->csets = cset;
9568 37704 item->frames = frames;
9569 37704 item->speed = speed;
9570 37704 item->delay = delay;
9571 37704 item->ltm = ltm;
9572 37704 }
9573 65728 }
9574
9575 33536 void reset_itemname(int32_t id)
9576 {
9577 33536 sprintf(item_string[id],"zz%03d",id);
9578
9579
2/2
✓ Branch 0 taken 14803 times.
✓ Branch 1 taken 18733 times.
33536 if(id < iLast)
9580 18733 strcpy(item_string[id],old_item_string[id]);
9581 33536 }
9582
9583 128 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9584 {
9585
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_weapons);
9586
9587 128 word weapons_to_read=MAXWPNS;
9588 int32_t dummy;
9589 byte padding;
9590 wpndata tempweapon;
9591 128 word s_version=0, s_cversion=0;
9592
9593
9594
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(Header->zelda_version < 0x186)
9595 {
9596 weapons_to_read=64;
9597 }
9598
9599
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(Header->zelda_version < 0x185)
9600 {
9601 weapons_to_read=32;
9602 }
9603
9604
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(Header->zelda_version > 0x192)
9605 {
9606 124 weapons_to_read=0;
9607
9608 //section version info
9609
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&s_version,f))
9610 {
9611 return qe_invalid;
9612 }
9613
9614 124 FFCore.quest_format[vWeaponSprites] = s_version;
9615
9616 //al_trace("Weapons version %d\n", s_version);
9617
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&s_cversion,f))
9618 {
9619 return qe_invalid;
9620 }
9621
9622 //section size
9623
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&dummy,f))
9624 {
9625 return qe_invalid;
9626 }
9627
9628 //finally... section data
9629
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&weapons_to_read,f))
9630 {
9631 return qe_invalid;
9632 }
9633
9634
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
124 if (!(weapons_to_read >= 0 && weapons_to_read <= MAXWPNS))
9635 {
9636 return qe_invalid;
9637 }
9638 124 }
9639
9640
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version>2)
9641 {
9642
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 112 times.
28784 for(int32_t i=0; i<weapons_to_read; i++)
9643 {
9644 char tempname[64];
9645
9646
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!pfread(tempname, 64, f))
9647 {
9648 return qe_invalid;
9649 }
9650
9651 28672 weapon_string[i][0] = '\0';
9652 28672 strncat(weapon_string[i], tempname, 64 - 1);
9653 28672 }
9654
9655
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(s_version<4)
9656 {
9657 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9658 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9659 }
9660
9661
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(s_version<5)
9662 {
9663 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9664 }
9665
9666 /*
9667 if (s_version<6)
9668 {
9669 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9670 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9671 }
9672 */
9673 112 }
9674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 else if (!should_skip)
9675 {
9676
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t i=0; i<MAXWPNS; i++)
9677 4096 reset_weaponname(i);
9678 16 }
9679
9680
2/2
✓ Branch 0 taken 30512 times.
✓ Branch 1 taken 128 times.
30640 for(int32_t i=0; i<weapons_to_read; i++)
9681 {
9682 30512 word oldtile = 0;
9683
2/2
✓ Branch 0 taken 8448 times.
✓ Branch 1 taken 22064 times.
30512 if (s_version < 8)
9684 {
9685
1/2
✓ Branch 0 taken 22064 times.
✗ Branch 1 not taken.
22064 if (!p_igetw(&oldtile, f))
9686 return qe_invalid;
9687 22064 }
9688
9689
1/2
✓ Branch 0 taken 30512 times.
✗ Branch 1 not taken.
30512 if(!p_getc(&tempweapon.misc,f))
9690 {
9691 return qe_invalid;
9692 }
9693
9694
1/2
✓ Branch 0 taken 30512 times.
✗ Branch 1 not taken.
30512 if(!p_getc(&tempweapon.csets,f))
9695 {
9696 return qe_invalid;
9697 }
9698
9699
1/2
✓ Branch 0 taken 30512 times.
✗ Branch 1 not taken.
30512 if(!p_getc(&tempweapon.frames,f))
9700 {
9701 return qe_invalid;
9702 }
9703
9704
1/2
✓ Branch 0 taken 30512 times.
✗ Branch 1 not taken.
30512 if(!p_getc(&tempweapon.speed,f))
9705 {
9706 return qe_invalid;
9707 }
9708
9709
1/2
✓ Branch 0 taken 30512 times.
✗ Branch 1 not taken.
30512 if(!p_getc(&tempweapon.type,f))
9710 {
9711 return qe_invalid;
9712 }
9713
9714
2/2
✓ Branch 0 taken 21552 times.
✓ Branch 1 taken 8960 times.
30512 if ( s_version >= 7 )
9715 {
9716
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetw(&tempweapon.script,f))
9717 {
9718 return qe_invalid;
9719 }
9720
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempweapon.tile,f))
9721 {
9722 return qe_invalid;
9723 }
9724 8960 }
9725
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 21552 times.
30512 if ( s_version < 7 )
9726 {
9727 21552 tempweapon.tile = oldtile;
9728 21552 }
9729
9730
2/2
✓ Branch 0 taken 29488 times.
✓ Branch 1 taken 1024 times.
30512 if(Header->zelda_version < 0x193)
9731 {
9732
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f))
9733 {
9734 return qe_invalid;
9735 }
9736 1024 }
9737
9738
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 1840 times.
30512 if(s_version < 6)
9739 {
9740
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1836 times.
1840 if(i==ewFIRETRAIL)
9741 {
9742 4 tempweapon.misc |= WF_BEHIND;
9743 4 }
9744 else
9745 1836 tempweapon.misc &= ~WF_BEHIND;
9746 1840 }
9747
9748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30512 times.
30512 if (!should_skip)
9749 30512 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9750 30512 }
9751
9752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (should_skip)
9753 return 0;
9754
9755
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version<2)
9756 {
9757 16 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9758 16 }
9759
9760
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version<5)
9761 {
9762 16 wpnsbuf[iwQuarterHearts].tile=1;
9763 16 wpnsbuf[iwQuarterHearts].csets=1;
9764 16 }
9765
9766
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(Header->zelda_version < 0x176)
9767 {
9768 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9769 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9770 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9771 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9772 }
9773
9774
2/4
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
128 if((Header->zelda_version < 0x192)||
9775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9776 {
9777 4 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9778 4 }
9779
9780
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if((Header->zelda_version < 0x210))
9781 {
9782 4 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9783 4 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9784 4 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9785 4 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9786 4 }
9787
9788 128 return 0;
9789 128 }
9790
9791 128 void init_guys(int32_t guyversion)
9792 {
9793
2/2
✓ Branch 0 taken 65536 times.
✓ Branch 1 taken 128 times.
65664 for(int32_t i=0; i<MAXGUYS; i++)
9794 {
9795 65536 guysbuf[i] = default_guys[0];
9796 65536 }
9797
9798
2/2
✓ Branch 0 taken 22656 times.
✓ Branch 1 taken 128 times.
22784 for(int32_t i=0; i<OLDMAXGUYS; i++)
9799 {
9800 22656 guysbuf[i] = default_guys[i];
9801
2/2
✓ Branch 0 taken 22400 times.
✓ Branch 1 taken 256 times.
22656 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9802 22656 guysbuf[i].spr_death = iwDeath;
9803 22656 guysbuf[i].spr_spawn = iwSpawn;
9804 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9805
4/4
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 19824 times.
✓ Branch 2 taken 2816 times.
✓ Branch 3 taken 16 times.
22656 if(guyversion<=3 && i==ePATRABS)
9806 {
9807 16 guysbuf[i].bosspal=spDIG;
9808 16 guysbuf[i].cset=14;
9809 16 guysbuf[i].misc9=14;
9810 16 }
9811
9812
2/2
✓ Branch 0 taken 19824 times.
✓ Branch 1 taken 2832 times.
22656 if(guyversion<=3)
9813 {
9814 // Rope/Ghini Flash rules
9815
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 2124 times.
2832 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9816 {
9817
2/2
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
2124 if(i==eROPE2)
9818 {
9819 12 guysbuf[i].flags2 &= ~guy_flashing;
9820 12 }
9821 2124 }
9822
9823
2/2
✓ Branch 0 taken 2301 times.
✓ Branch 1 taken 531 times.
2832 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9824 {
9825
12/12
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 525 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 522 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 519 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 516 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 513 times.
531 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9826 {
9827 18 guysbuf[i].flags2 &= ~guy_flashing;
9828 18 }
9829 531 }
9830
9831
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 16 times.
2832 if(i==eGHINI2)
9832 {
9833
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
16 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9834 {
9835 3 guysbuf[i].flags2 |= guy_blinking;
9836 3 }
9837
9838
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9839 {
9840 guysbuf[i].flags2 |= guy_transparent;
9841 }
9842 16 }
9843 2832 }
9844
9845 // Darknut fix
9846
10/10
✓ Branch 0 taken 22528 times.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 22400 times.
✓ Branch 3 taken 128 times.
✓ Branch 4 taken 22272 times.
✓ Branch 5 taken 128 times.
✓ Branch 6 taken 22144 times.
✓ Branch 7 taken 128 times.
✓ Branch 8 taken 128 times.
✓ Branch 9 taken 22016 times.
22656 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9847 {
9848
2/2
✓ Branch 0 taken 430 times.
✓ Branch 1 taken 210 times.
640 if(get_qr(qr_NEWENEMYTILES))
9849 {
9850 430 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9851 430 guysbuf[i].s_width=guysbuf[i].e_width;
9852 430 guysbuf[i].s_height=guysbuf[i].e_height;
9853 430 }
9854 210 else guysbuf[i].s_tile=860;
9855
9856
2/2
✓ Branch 0 taken 560 times.
✓ Branch 1 taken 80 times.
640 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9857 {
9858 80 guysbuf[i].flags |= guy_bkshield;
9859 80 }
9860 640 }
9861
9862
4/4
✓ Branch 0 taken 22528 times.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 22648 times.
✓ Branch 3 taken 8 times.
22656 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9863 {
9864 8 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9865 8 }
9866 22656 }
9867 128 }
9868
9869 4096 void reset_weaponname(int32_t i)
9870 {
9871
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 2688 times.
4096 if(i<wLast)
9872 {
9873 1408 strcpy(weapon_string[i],old_weapon_string[i]);
9874 1408 }
9875 else
9876 2688 sprintf(weapon_string[i],"zz%03d",i);
9877 4096 }
9878
9879 128 void init_item_drop_sets()
9880 {
9881
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9882 {
9883 // item_drop_sets[i] = default_item_drop_sets[0];
9884 32768 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9885 32768 }
9886
9887
2/2
✓ Branch 0 taken 1664 times.
✓ Branch 1 taken 128 times.
1792 for(int32_t i=0; i<isMAX; i++)
9888 {
9889 1664 item_drop_sets[i] = default_item_drop_sets[i];
9890
9891 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9892
2/2
✓ Branch 0 taken 16640 times.
✓ Branch 1 taken 1664 times.
18304 for(int32_t j=0; j<10; ++j)
9893 {
9894 16640 int32_t it = item_drop_sets[i].item[j];
9895
9896
3/4
✓ Branch 0 taken 11684 times.
✓ Branch 1 taken 4956 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 750 times.
16640 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9897
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 10934 times.
11684 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9898 {
9899 750 item_drop_sets[i].chance[j+1]=0;
9900 750 }
9901
3/4
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 15378 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 512 times.
15890 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9902 {
9903 item_drop_sets[i].chance[j+1]=0;
9904 }
9905
9906 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9907
2/2
✓ Branch 0 taken 16632 times.
✓ Branch 1 taken 8 times.
16640 if(itemsbuf[it].family == itype_misc)
9908 {
9909 // If a non-gameplay item was selected, then item drop was aborted.
9910 // Reflect this by increasing the 'Nothing' chance accordingly.
9911 8 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9912 8 item_drop_sets[i].chance[j+1]=0;
9913 8 }
9914 16640 }
9915 1664 }
9916 128 }
9917
9918 128 void init_favorites()
9919 {
9920
2/2
✓ Branch 0 taken 161280 times.
✓ Branch 1 taken 128 times.
161408 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9921 {
9922 161280 favorite_combos[i]=-1;
9923 161280 }
9924 128 }
9925
9926 const char *ctype_name[cMAX]=
9927 {
9928 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9929 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9930 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9931 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9932 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9933 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9934 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9935 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9936 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9937 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9938 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9939 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9940 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9941 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9942 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9943 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9944 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9945 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9946 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9947 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9948 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9949 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9950 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9951 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9952 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9953 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9954 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9955 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9956
9957 };
9958
9959 223 int32_t init_combo_classes()
9960 {
9961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 223 times.
223 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9962
2/2
✓ Branch 0 taken 40586 times.
✓ Branch 1 taken 223 times.
40809 for(int32_t i=0; i<cMAX; i++)
9963 {
9964 40586 combo_class_buf[i] = default_combo_classes[i];
9965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40586 times.
40586 if ( char const* nm = zi->getComboTypeName(i) )
9966 {
9967 40586 size_t len = strlen(nm);
9968
2/2
✓ Branch 0 taken 2597504 times.
✓ Branch 1 taken 40586 times.
2638090 for ( size_t q = 0; q < 64; q++ )
9969 {
9970
2/2
✓ Branch 0 taken 595856 times.
✓ Branch 1 taken 2001648 times.
2597504 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9971 2597504 }
9972 40586 }
9973 40586 }
9974
9975 223 return 0;
9976 }
9977
9978 97 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
9979 {
9980
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 89 times.
97 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_herosprites);
9981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if (should_skip) return 0;
9982
9983
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 assert(v_herosprites < 6);
9984 //these are here to bypass compiler warnings about unused arguments
9985 97 cv_herosprites=cv_herosprites;
9986
9987 97 zinit.hero_swim_speed=67; //default
9988 97 setupherotiles(zinit.heroAnimationStyle);
9989 97 setupherodefenses();
9990 97 setupherooffsets();
9991
9992
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 77 times.
97 if(v_herosprites>=0)
9993 {
9994 word tile, tile2;
9995 byte flip, extend, dummy_byte;
9996
9997
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
9998 {
9999
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10000 {
10001 return qe_invalid;
10002 }
10003
10004
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10005 {
10006 return qe_invalid;
10007 }
10008
10009
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10010 {
10011 return qe_invalid;
10012 }
10013
10014 308 walkspr[i][spr_tile]=(int32_t)tile;
10015 308 walkspr[i][spr_flip]=(int32_t)flip;
10016 308 walkspr[i][spr_extend]=(int32_t)extend;
10017 308 }
10018
10019
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10020 {
10021
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10022 {
10023 return qe_invalid;
10024 }
10025
10026
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10027 {
10028 return qe_invalid;
10029 }
10030
10031
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10032 {
10033 return qe_invalid;
10034 }
10035
10036 308 stabspr[i][spr_tile]=(int32_t)tile;
10037 308 stabspr[i][spr_flip]=(int32_t)flip;
10038 308 stabspr[i][spr_extend]=(int32_t)extend;
10039 308 }
10040
10041
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10042 {
10043
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10044 {
10045 return qe_invalid;
10046 }
10047
10048
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10049 {
10050 return qe_invalid;
10051 }
10052
10053
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10054 {
10055 return qe_invalid;
10056 }
10057
10058 308 slashspr[i][spr_tile]=(int32_t)tile;
10059 308 slashspr[i][spr_flip]=(int32_t)flip;
10060 308 slashspr[i][spr_extend]=(int32_t)extend;
10061 308 }
10062
10063
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10064 {
10065
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10066 {
10067 return qe_invalid;
10068 }
10069
10070
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10071 {
10072 return qe_invalid;
10073 }
10074
10075
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10076 {
10077 return qe_invalid;
10078 }
10079
10080 308 floatspr[i][spr_tile]=(int32_t)tile;
10081 308 floatspr[i][spr_flip]=(int32_t)flip;
10082 308 floatspr[i][spr_extend]=(int32_t)extend;
10083 308 }
10084
10085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>1)
10086 {
10087
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10088 {
10089
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10090 {
10091 return qe_invalid;
10092 }
10093
10094
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10095 {
10096 return qe_invalid;
10097 }
10098
10099
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10100 {
10101 return qe_invalid;
10102 }
10103
10104 308 swimspr[i][spr_tile]=(int32_t)tile;
10105 308 swimspr[i][spr_flip]=(int32_t)flip;
10106 308 swimspr[i][spr_extend]=(int32_t)extend;
10107 308 }
10108 77 }
10109
10110
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10111 {
10112
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10113 {
10114 return qe_invalid;
10115 }
10116
10117
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10118 {
10119 return qe_invalid;
10120 }
10121
10122
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10123 {
10124 return qe_invalid;
10125 }
10126
10127 308 divespr[i][spr_tile]=(int32_t)tile;
10128 308 divespr[i][spr_flip]=(int32_t)flip;
10129 308 divespr[i][spr_extend]=(int32_t)extend;
10130 308 }
10131
10132
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10133 {
10134
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10135 {
10136 return qe_invalid;
10137 }
10138
10139
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10140 {
10141 return qe_invalid;
10142 }
10143
10144
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10145 {
10146 return qe_invalid;
10147 }
10148
10149 308 poundspr[i][spr_tile]=(int32_t)tile;
10150 308 poundspr[i][spr_flip]=(int32_t)flip;
10151 308 poundspr[i][spr_extend]=(int32_t)extend;
10152 308 }
10153
10154
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&tile,f))
10155 {
10156 return qe_invalid;
10157 }
10158
10159 77 flip=0;
10160
10161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>0)
10162 {
10163
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&flip,f))
10164 {
10165 return qe_invalid;
10166 }
10167 77 }
10168
10169
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&extend,f))
10170 {
10171 return qe_invalid;
10172 }
10173
10174 77 castingspr[spr_tile]=(int32_t)tile;
10175 77 castingspr[spr_flip]=(int32_t)flip;
10176 77 castingspr[spr_extend]=(int32_t)extend;
10177
10178
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(v_herosprites>0)
10179 {
10180 77 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10181
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 77 times.
231 for(int32_t i=0; i<2; i++)
10182 {
10183
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 154 times.
462 for(int32_t j=0; j<num_holdsprs; j++)
10184 {
10185
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10186 {
10187 return qe_invalid;
10188 }
10189
10190
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10191 {
10192 return qe_invalid;
10193 }
10194
10195
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10196 {
10197 return qe_invalid;
10198 }
10199
10200 308 holdspr[i][j][spr_tile]=(int32_t)tile;
10201 308 holdspr[i][j][spr_flip]=(int32_t)flip;
10202 308 holdspr[i][j][spr_extend]=(int32_t)extend;
10203 308 }
10204 154 }
10205 77 }
10206 else
10207 {
10208 for(int32_t i=0; i<2; i++)
10209 {
10210 if(!p_igetw(&tile,f))
10211 {
10212 return qe_invalid;
10213 }
10214
10215 if(!p_igetw(&tile2,f))
10216 {
10217 return qe_invalid;
10218 }
10219
10220 if(!p_getc(&extend,f))
10221 {
10222 return qe_invalid;
10223 }
10224
10225 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10226 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10227 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10228 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10229 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10230 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10231 }
10232 }
10233
10234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>2)
10235 {
10236
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10237 {
10238
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10239 {
10240 return qe_invalid;
10241 }
10242
10243
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10244 {
10245 return qe_invalid;
10246 }
10247
10248
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10249 {
10250 return qe_invalid;
10251 }
10252
10253 308 jumpspr[i][spr_tile]=(int32_t)tile;
10254 308 jumpspr[i][spr_flip]=(int32_t)flip;
10255 308 jumpspr[i][spr_extend]=(int32_t)extend;
10256 308 }
10257 77 }
10258
10259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>3)
10260 {
10261
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10262 {
10263
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10264 {
10265 return qe_invalid;
10266 }
10267
10268
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10269 {
10270 return qe_invalid;
10271 }
10272
10273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 308 times.
308 if(!p_getc(&extend,f))
10274 {
10275 return qe_invalid;
10276 }
10277
10278 308 chargespr[i][spr_tile]=(int32_t)tile;
10279 308 chargespr[i][spr_flip]=(int32_t)flip;
10280 308 chargespr[i][spr_extend]=(int32_t)extend;
10281 308 }
10282 77 }
10283
10284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>4)
10285 {
10286
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&dummy_byte,f))
10287 {
10288 return qe_invalid;
10289 }
10290
10291 77 zinit.hero_swim_speed=(byte)dummy_byte;
10292 77 }
10293
10294 77 memset(frozenspr, 0, sizeof(frozenspr));
10295 77 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10296 77 memset(onfirespr, 0, sizeof(onfirespr));
10297 77 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10298 77 memset(diggingspr, 0, sizeof(diggingspr));
10299 77 memset(usingrodspr, 0, sizeof(usingrodspr));
10300 77 memset(usingcanespr, 0, sizeof(usingcanespr));
10301 77 memset(pushingspr, 0, sizeof(pushingspr));
10302 77 memset(liftingspr, 0, sizeof(liftingspr));
10303 77 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10304 77 memset(stunnedspr, 0, sizeof(stunnedspr));
10305 77 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10306 77 memset(fallingspr, 0, sizeof(fallingspr));
10307 77 memset(shockedspr, 0, sizeof(shockedspr));
10308 77 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10309 77 memset(pullswordspr, 0, sizeof(pullswordspr));
10310 77 memset(readingspr, 0, sizeof(readingspr));
10311 77 memset(slash180spr, 0, sizeof(slash180spr));
10312 77 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10313 77 memset(dashspr, 0, sizeof(dashspr));
10314 77 memset(bonkspr, 0, sizeof(bonkspr));
10315 77 memset(medallionsprs, 0, sizeof(medallionsprs));
10316 77 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10317 77 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10318
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t q = 0; q < 4; ++q)
10319 {
10320
2/2
✓ Branch 0 taken 924 times.
✓ Branch 1 taken 308 times.
1232 for(int32_t p = 0; p < 3; ++p)
10321 {
10322 924 drowningspr[q][p] = divespr[q][p];
10323 924 drowning_lavaspr[q][p] = divespr[q][p];
10324 924 }
10325 308 }
10326 77 memset(sideswimspr, 0, sizeof(sideswimspr));
10327 77 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10328 77 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10329 77 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10330 77 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10331 77 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10332 77 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10333 77 }
10334
10335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(FFCore.quest_format[vInitData] < 34)
10336 {
10337 97 bool fastswim = zinit.hero_swim_speed > 60;
10338 // '2/3' or '1/2'
10339 97 zinit.hero_swim_mult = fastswim ? 2 : 1;
10340 97 zinit.hero_swim_div = fastswim ? 3 : 2;
10341 97 }
10342 97 return 0;
10343 97 }
10344
10345 5950 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10346 {
10347 5950 arr[spr_tile] = tile;
10348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5950 times.
5950 arr[spr_flip] = (flip > 3 ? 0 : flip);
10349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5950 times.
5950 arr[spr_extend] = (ext > 2 ? 0 : ext);
10350 5950 }
10351 //Used to read the player sprites as int32_t, not word.
10352 35 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
10353 {
10354 //these are here to bypass compiler warnings about unused arguments
10355 35 cv_herosprites=cv_herosprites;
10356
10357 35 zinit.hero_swim_speed=67; //default
10358 35 setupherotiles(zinit.heroAnimationStyle);
10359 35 setupherodefenses();
10360 35 setupherooffsets();
10361
10362 int32_t tile, tile2;
10363 byte flip, extend, dummy_byte;
10364
10365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(v_herosprites>=0)
10366 {
10367
10368
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t i=0; i<4; i++)
10369 {
10370
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10371 {
10372 return qe_invalid;
10373 }
10374
10375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10376 {
10377 return qe_invalid;
10378 }
10379
10380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10381 {
10382 return qe_invalid;
10383 }
10384
10385 140 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10386 140 }
10387
10388
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t i=0; i<4; i++)
10389 {
10390
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10391 {
10392 return qe_invalid;
10393 }
10394
10395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10396 {
10397 return qe_invalid;
10398 }
10399
10400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10401 {
10402 return qe_invalid;
10403 }
10404
10405 140 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10406 140 }
10407
10408
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t i=0; i<4; i++)
10409 {
10410
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10411 {
10412 return qe_invalid;
10413 }
10414
10415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10416 {
10417 return qe_invalid;
10418 }
10419
10420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10421 {
10422 return qe_invalid;
10423 }
10424
10425 140 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10426 140 }
10427
10428
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t i=0; i<4; i++)
10429 {
10430
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10431 {
10432 return qe_invalid;
10433 }
10434
10435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10436 {
10437 return qe_invalid;
10438 }
10439
10440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10441 {
10442 return qe_invalid;
10443 }
10444
10445 140 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10446 140 }
10447
10448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(v_herosprites>1)
10449 {
10450
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t i=0; i<4; i++)
10451 {
10452
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10453 {
10454 return qe_invalid;
10455 }
10456
10457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10458 {
10459 return qe_invalid;
10460 }
10461
10462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10463 {
10464 return qe_invalid;
10465 }
10466
10467 140 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10468 140 }
10469 35 }
10470
10471
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t i=0; i<4; i++)
10472 {
10473
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10474 {
10475 return qe_invalid;
10476 }
10477
10478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10479 {
10480 return qe_invalid;
10481 }
10482
10483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10484 {
10485 return qe_invalid;
10486 }
10487
10488 140 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10489 140 }
10490
10491
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t i=0; i<4; i++)
10492 {
10493
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10494 {
10495 return qe_invalid;
10496 }
10497
10498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10499 {
10500 return qe_invalid;
10501 }
10502
10503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10504 {
10505 return qe_invalid;
10506 }
10507
10508 140 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10509 140 }
10510
10511
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tile,f))
10512 {
10513 return qe_invalid;
10514 }
10515
10516 35 flip=0;
10517
10518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(v_herosprites>0)
10519 {
10520
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&flip,f))
10521 {
10522 return qe_invalid;
10523 }
10524 35 }
10525
10526
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&extend,f))
10527 {
10528 return qe_invalid;
10529 }
10530
10531 35 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10532
10533
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(v_herosprites>0)
10534 {
10535 35 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10536
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 35 times.
105 for(int32_t i=0; i<2; i++)
10537 {
10538
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 70 times.
280 for(int32_t j=0; j<num_holdsprs; j++)
10539 {
10540
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(!p_igetl(&tile,f))
10541 {
10542 return qe_invalid;
10543 }
10544
10545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(!p_getc(&flip,f))
10546 {
10547 return qe_invalid;
10548 }
10549
10550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(!p_getc(&extend,f))
10551 {
10552 return qe_invalid;
10553 }
10554
10555 210 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10556 210 }
10557 70 }
10558 35 }
10559 else
10560 {
10561 for(int32_t i=0; i<2; i++)
10562 {
10563 if(!p_igetl(&tile,f))
10564 {
10565 return qe_invalid;
10566 }
10567
10568 if(!p_igetl(&tile2,f))
10569 {
10570 return qe_invalid;
10571 }
10572
10573 if(!p_getc(&extend,f))
10574 {
10575 return qe_invalid;
10576 }
10577
10578 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10579 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10580 }
10581 }
10582
10583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(v_herosprites>2)
10584 {
10585
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t i=0; i<4; i++)
10586 {
10587
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10588 {
10589 return qe_invalid;
10590 }
10591
10592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10593 {
10594 return qe_invalid;
10595 }
10596
10597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10598 {
10599 return qe_invalid;
10600 }
10601
10602 140 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10603 140 }
10604 35 }
10605
10606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(v_herosprites>3)
10607 {
10608
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t i=0; i<4; i++)
10609 {
10610
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10611 {
10612 return qe_invalid;
10613 }
10614
10615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10616 {
10617 return qe_invalid;
10618 }
10619
10620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10621 {
10622 return qe_invalid;
10623 }
10624
10625 140 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10626 140 }
10627 35 }
10628
10629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(v_herosprites>4)
10630 {
10631
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&dummy_byte,f))
10632 {
10633 return qe_invalid;
10634 }
10635
10636 35 zinit.hero_swim_speed=(byte)dummy_byte;
10637 35 }
10638
10639
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(v_herosprites>6)
10640 {
10641
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10642 {
10643
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10644 return qe_invalid;
10645
10646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10647 return qe_invalid;
10648
10649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10650 return qe_invalid;
10651
10652 140 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10653 140 }
10654
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10655 {
10656
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10657 return qe_invalid;
10658
10659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10660 return qe_invalid;
10661
10662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10663 return qe_invalid;
10664
10665 140 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10666 140 }
10667
10668
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10669 {
10670
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10671 return qe_invalid;
10672
10673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10674 return qe_invalid;
10675
10676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10677 return qe_invalid;
10678
10679 140 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10680 140 }
10681
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10682 {
10683
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10684 return qe_invalid;
10685
10686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10687 return qe_invalid;
10688
10689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10690 return qe_invalid;
10691
10692 140 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10693 140 }
10694
10695
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10696 {
10697
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10698 return qe_invalid;
10699
10700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10701 return qe_invalid;
10702
10703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10704 return qe_invalid;
10705
10706 140 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10707 140 }
10708
10709
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10710 {
10711
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10712 return qe_invalid;
10713
10714
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10715 return qe_invalid;
10716
10717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10718 return qe_invalid;
10719
10720 140 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10721 140 }
10722
10723
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10724 {
10725
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10726 return qe_invalid;
10727
10728
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10729 return qe_invalid;
10730
10731
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&extend,f))
10732 return qe_invalid;
10733
10734 140 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10735 140 }
10736
10737
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10738 {
10739
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10740 return qe_invalid;
10741
10742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10743 return qe_invalid;
10744
10745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10746 return qe_invalid;
10747
10748 140 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10749 140 }
10750
10751
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10752 {
10753
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10754 return qe_invalid;
10755
10756
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10757 return qe_invalid;
10758
10759
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&extend,f))
10760 return qe_invalid;
10761
10762 140 byte frames = 0;
10763
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 132 times.
140 if(v_herosprites > 15)
10764 {
10765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(!p_getc(&frames,f))
10766 return qe_invalid;
10767 132 }
10768
10769 140 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10770 140 liftingspr[q][spr_frames] = frames;
10771 140 }
10772
10773
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10774 {
10775
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10776 return qe_invalid;
10777
10778
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10779 return qe_invalid;
10780
10781
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&extend,f))
10782 return qe_invalid;
10783
10784 140 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10785 140 }
10786
10787
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10788 {
10789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_igetl(&tile,f))
10790 return qe_invalid;
10791
10792
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10793 return qe_invalid;
10794
10795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10796 return qe_invalid;
10797
10798 140 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10799 140 }
10800
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10801 {
10802
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10803 return qe_invalid;
10804
10805
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10806 return qe_invalid;
10807
10808
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&extend,f))
10809 return qe_invalid;
10810
10811 140 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10812 140 }
10813
10814
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10815 {
10816
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10817 return qe_invalid;
10818
10819
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10820 return qe_invalid;
10821
10822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10823 return qe_invalid;
10824
10825 140 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10826 140 }
10827
10828
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10829 {
10830
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10831 return qe_invalid;
10832
10833
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10834 return qe_invalid;
10835
10836
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&extend,f))
10837 return qe_invalid;
10838
10839 140 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10840 140 }
10841
10842
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10843 {
10844
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10845 return qe_invalid;
10846
10847
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10848 return qe_invalid;
10849
10850
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&extend,f))
10851 return qe_invalid;
10852
10853 140 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10854 140 }
10855
10856
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10857 {
10858
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10859 return qe_invalid;
10860
10861
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10862 return qe_invalid;
10863
10864
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&extend,f))
10865 return qe_invalid;
10866
10867 140 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10868 140 }
10869
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10870 {
10871
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10872 return qe_invalid;
10873
10874
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10875 return qe_invalid;
10876
10877
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&extend,f))
10878 return qe_invalid;
10879
10880 140 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10881 140 }
10882
10883
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10884 {
10885
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10886 return qe_invalid;
10887
10888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10889 return qe_invalid;
10890
10891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10892 return qe_invalid;
10893
10894 140 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10895 140 }
10896
10897
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10898 {
10899
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10900 return qe_invalid;
10901
10902
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10903 return qe_invalid;
10904
10905
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&extend,f))
10906 return qe_invalid;
10907
10908 140 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10909 140 }
10910
10911
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10912 {
10913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_igetl(&tile,f))
10914 return qe_invalid;
10915
10916
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10917 return qe_invalid;
10918
10919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10920 return qe_invalid;
10921
10922 140 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10923 140 }
10924
10925
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10926 {
10927
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10928 return qe_invalid;
10929
10930
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10931 return qe_invalid;
10932
10933
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&extend,f))
10934 return qe_invalid;
10935
10936 140 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10937 140 }
10938
10939
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10940 {
10941
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10942 return qe_invalid;
10943
10944
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10945 return qe_invalid;
10946
10947
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&extend,f))
10948 return qe_invalid;
10949
10950 140 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10951 140 }
10952
10953
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10954 {
10955
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10956 return qe_invalid;
10957
10958
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10959 return qe_invalid;
10960
10961
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&extend,f))
10962 return qe_invalid;
10963
10964 140 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10965 140 }
10966
10967
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 35 times.
140 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10968 {
10969
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&tile,f))
10970 return qe_invalid;
10971
10972
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&flip,f))
10973 return qe_invalid;
10974
10975
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&extend,f))
10976 return qe_invalid;
10977
10978 105 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10979 105 }
10980 35 }
10981 else
10982 {
10983 memset(frozenspr, 0, sizeof(frozenspr));
10984 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10985 memset(onfirespr, 0, sizeof(onfirespr));
10986 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10987 memset(diggingspr, 0, sizeof(diggingspr));
10988 memset(usingrodspr, 0, sizeof(usingrodspr));
10989 memset(usingcanespr, 0, sizeof(usingcanespr));
10990 memset(pushingspr, 0, sizeof(pushingspr));
10991 memset(liftingspr, 0, sizeof(liftingspr));
10992 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10993 memset(stunnedspr, 0, sizeof(stunnedspr));
10994 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10995 memset(fallingspr, 0, sizeof(fallingspr));
10996 memset(shockedspr, 0, sizeof(shockedspr));
10997 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10998 memset(pullswordspr, 0, sizeof(pullswordspr));
10999 memset(readingspr, 0, sizeof(readingspr));
11000 memset(slash180spr, 0, sizeof(slash180spr));
11001 memset(slashZ4spr, 0, sizeof(slashZ4spr));
11002 memset(dashspr, 0, sizeof(dashspr));
11003 memset(bonkspr, 0, sizeof(bonkspr));
11004 memset(medallionsprs, 0, sizeof(medallionsprs));
11005 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11006 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11007 for(int32_t q = 0; q < 4; ++q)
11008 {
11009 for(int32_t p = 0; p < 3; ++p)
11010 {
11011 drowningspr[q][p] = divespr[q][p];
11012 drowning_lavaspr[q][p] = divespr[q][p];
11013 }
11014 }
11015 }
11016
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if (v_herosprites > 8)
11017 {
11018
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
11019 {
11020
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
11021 return qe_invalid;
11022
11023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
11024 return qe_invalid;
11025
11026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
11027 return qe_invalid;
11028
11029 140 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11030 140 }
11031 35 }
11032 else
11033 {
11034 memset(sideswimspr, 0, sizeof(sideswimspr));
11035 }
11036
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if (v_herosprites > 9)
11037 {
11038
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
11039 {
11040
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
11041 return qe_invalid;
11042
11043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
11044 return qe_invalid;
11045
11046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
11047 return qe_invalid;
11048
11049 140 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11050 140 }
11051
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
11052 {
11053
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
11054 return qe_invalid;
11055
11056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
11057 return qe_invalid;
11058
11059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
11060 return qe_invalid;
11061
11062 140 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11063 140 }
11064
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
11065 {
11066
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
11067 return qe_invalid;
11068
11069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
11070 return qe_invalid;
11071
11072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
11073 return qe_invalid;
11074
11075 140 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11076 140 }
11077
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
11078 {
11079
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
11080 return qe_invalid;
11081
11082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
11083 return qe_invalid;
11084
11085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
11086 return qe_invalid;
11087
11088 140 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11089 140 }
11090 35 }
11091 else
11092 {
11093 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11094 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11095 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11096 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11097 }
11098
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if (v_herosprites > 10)
11099 {
11100
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
11101 {
11102 int32_t hmr;
11103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_igetl(&hmr,f))
11104 return qe_invalid;
11105
11106 140 hammeroffsets[q] = hmr;
11107 140 }
11108 35 }
11109 else
11110 {
11111 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11112 }
11113
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if (v_herosprites > 11)
11114 {
11115
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 35 times.
140 for(int32_t q = 0; q < 3; ++q)
11116 {
11117
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&tile,f))
11118 return qe_invalid;
11119
11120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(!p_getc(&flip,f))
11121 return qe_invalid;
11122
11123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(!p_getc(&extend,f))
11124 return qe_invalid;
11125
11126 105 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11127 105 }
11128 35 }
11129 else
11130 {
11131 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11132 }
11133
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if (v_herosprites > 12)
11134 {
11135
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tile,f))
11136 return qe_invalid;
11137
11138
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&flip,f))
11139 return qe_invalid;
11140
11141
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&extend,f))
11142 return qe_invalid;
11143 35 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11144
11145 35 }
11146 else
11147 {
11148 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11149 }
11150
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if (v_herosprites > 13)
11151 {
11152
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
11153 {
11154
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
11155 return qe_invalid;
11156
11157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
11158 return qe_invalid;
11159
11160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
11161 return qe_invalid;
11162
11163 140 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11164 140 }
11165 35 }
11166 else
11167 {
11168 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11169 }
11170
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if (v_herosprites > 14)
11171 {
11172
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
11173 {
11174
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
11175 return qe_invalid;
11176
11177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
11178 return qe_invalid;
11179
11180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
11181 return qe_invalid;
11182
11183 140 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11184 140 }
11185 35 }
11186 else
11187 {
11188 memset(revslashspr, 0, sizeof(revslashspr));
11189 }
11190
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if (v_herosprites > 7)
11191 {
11192 35 int32_t num_defense = wMax;
11193 35 byte def = 0;
11194
11195 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11196 /*if(v_herosprites > [x])
11197 * {
11198 * num_defense = 146 //value of wMax on version 8
11199 * }
11200 */
11201
11202
2/2
✓ Branch 0 taken 5110 times.
✓ Branch 1 taken 35 times.
5145 for (int32_t q = 0; q < num_defense; q++)
11203 {
11204
1/2
✓ Branch 0 taken 5110 times.
✗ Branch 1 not taken.
5110 if (!p_getc(&def, f))
11205 return qe_invalid;
11206
11207 5110 hero_defence[q] = def;
11208 5110 }
11209 35 }
11210 else
11211 {
11212 int32_t num_defense = wMax;
11213 for (int32_t q = 0; q < num_defense; q++)
11214 {
11215 hero_defence[q] = 0;
11216 }
11217 }
11218 35 }
11219
11220
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 5 times.
35 if(FFCore.quest_format[vInitData] < 34)
11221 {
11222 5 bool fastswim = zinit.hero_swim_speed > 60;
11223 // '2/3' or '1/2'
11224 5 zinit.hero_swim_mult = fastswim ? 2 : 1;
11225 5 zinit.hero_swim_div = fastswim ? 3 : 2;
11226 5 }
11227 35 return 0;
11228 35 }
11229
11230
11231 112 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11232 {
11233 //these are here to bypass compiler warnings about unused arguments
11234 112 Header=Header;
11235
11236 dword dummy;
11237 112 word s_version=0, s_cversion=0;
11238
11239 //section version info
11240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(!p_igetw(&s_version,f))
11241 {
11242 return qe_invalid;
11243 }
11244
11245 112 FFCore.quest_format[vHeroSprites] = s_version;
11246
11247 //al_trace("Player sprites version %d\n", s_version);
11248
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetw(&s_cversion,f))
11249 {
11250 return qe_invalid;
11251 }
11252
11253 //section size
11254
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetl(&dummy,f))
11255 {
11256 return qe_invalid;
11257 }
11258
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 77 times.
112 if ( s_version >= 6 )
11259 {
11260 //al_trace("Reading Player Sprites v6\n");
11261 35 return readherosprites3(f, s_version, dummy);
11262 }
11263 77 else return readherosprites2(f, s_version, dummy);
11264 112 }
11265
11266 86 int32_t read_old_subscreens(PACKFILE *f, word s_version)
11267 {
11268 86 subscreens_active.clear();
11269 86 subscreens_passive.clear();
11270 86 subscreens_overlay.clear();
11271
2/2
✓ Branch 0 taken 11008 times.
✓ Branch 1 taken 86 times.
11094 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11272 {
11273 subscreen_group g;
11274 11008 memset(&g,0,sizeof(subscreen_group));
11275 11008 int32_t ret = read_one_old_subscreen(f, &g, s_version);
11276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11008 times.
11008 if(ret!=0)
11277 return ret;
11278
2/2
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 10613 times.
11008 if(g.objects[0].type == ssoNULL) continue;
11279
2/2
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 207 times.
395 auto& vec = g.ss_type == sstPASSIVE ? subscreens_passive : subscreens_active;
11280 395 ZCSubscreen& sub = vec.emplace_back();
11281 395 sub.load_old(g);
11282 395 }
11283
11284 86 return 0;
11285 86 }
11286
11287 11008 int32_t read_one_old_subscreen(PACKFILE *f, subscreen_group* g, word s_version)
11288 {
11289 11008 int32_t numsub=0;
11290 11008 byte temp_ss=0;
11291 subscreen_object temp_sub_stack;
11292 11008 subscreen_object *temp_sub = &temp_sub_stack;
11293
11294 char tempname[64];
11295
11296 // FWIW I never saw anything bigger than 20.
11297 #define MAX_DP1_LEN 1024
11298 char tempdp1[MAX_DP1_LEN];
11299
11300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11008 times.
11008 if(!pfread(tempname,64,f))
11301 {
11302 return qe_invalid;
11303 }
11304
11305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11008 times.
11008 if(s_version > 1)
11306 {
11307
1/2
✓ Branch 0 taken 11008 times.
✗ Branch 1 not taken.
11008 if(!p_getc(&temp_ss,f))
11308 {
11309 return qe_invalid;
11310 }
11311 11008 }
11312
11313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11008 times.
11008 if(s_version < 4)
11314 {
11315 uint8_t tmp=0;
11316
11317 if(!p_getc(&tmp,f))
11318 {
11319 return qe_invalid;
11320 }
11321
11322 numsub = (int32_t)tmp;
11323 }
11324 else
11325 {
11326 word tmp;
11327
11328
1/2
✓ Branch 0 taken 11008 times.
✗ Branch 1 not taken.
11008 if(!p_igetw(&tmp, f))
11329 {
11330 return qe_invalid;
11331 }
11332
11333 11008 numsub = (int32_t)tmp;
11334 }
11335
11336 int32_t j;
11337
11338
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24251 times.
✓ Branch 2 taken 13243 times.
✓ Branch 3 taken 11008 times.
24251 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11339 {
11340 13243 memset(temp_sub,0,sizeof(subscreen_object));
11341
11342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13243 times.
13243 switch(g->objects[j].type)
11343 {
11344 case ssoTEXT:
11345 case ssoTEXTBOX:
11346 case ssoCURRENTITEMTEXT:
11347 case ssoCURRENTITEMCLASSTEXT:
11348 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11349
11350 //fall through
11351 default:
11352 13243 memset(&g->objects[j],0,sizeof(subscreen_object));
11353 13243 break;
11354 }
11355
11356
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->type),f))
11357 return qe_invalid;
11358
11359
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->pos),f))
11360 return qe_invalid;
11361
11362
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(s_version < 5)
11363 {
11364 switch(temp_sub->pos)
11365 {
11366 case 0:
11367 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11368 break;
11369
11370 case 1:
11371 temp_sub->pos = sspUP;
11372 break;
11373
11374 case 2:
11375 temp_sub->pos = sspDOWN;
11376 break;
11377
11378 default:
11379 temp_sub->pos = 0;
11380 }
11381 }
11382
11383
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->x),f))
11384 return qe_invalid;
11385
11386
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->y),f))
11387 return qe_invalid;
11388
11389
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->w),f))
11390 return qe_invalid;
11391
11392
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->h),f))
11393 return qe_invalid;
11394
11395
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->colortype1),f))
11396 return qe_invalid;
11397
11398
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->color1),f))
11399 return qe_invalid;
11400
11401
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->colortype2),f))
11402 return qe_invalid;
11403
11404
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->color2),f))
11405 return qe_invalid;
11406
11407
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->colortype3),f))
11408 return qe_invalid;
11409
11410
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->color3),f))
11411 return qe_invalid;
11412
11413
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d1),f))
11414 return qe_invalid;
11415
11416
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d2),f))
11417 return qe_invalid;
11418
11419
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d3),f))
11420 return qe_invalid;
11421
11422
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d4),f))
11423 return qe_invalid;
11424
11425
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d5),f))
11426 return qe_invalid;
11427
11428
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d6),f))
11429 return qe_invalid;
11430
11431
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d7),f))
11432 return qe_invalid;
11433
11434
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d8),f))
11435 return qe_invalid;
11436
11437
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d9),f))
11438 return qe_invalid;
11439
11440
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d10),f))
11441 return qe_invalid;
11442
11443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13243 times.
13243 if(s_version < 2)
11444 {
11445 if(!p_igetl(&(temp_sub->speed),f))
11446 return qe_invalid;
11447
11448 if(!p_igetl(&(temp_sub->delay),f))
11449 return qe_invalid;
11450
11451 if(!p_igetl(&(temp_sub->frame),f))
11452 return qe_invalid;
11453 }
11454 else
11455 {
11456
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->speed),f))
11457 return qe_invalid;
11458
11459
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->delay),f))
11460 return qe_invalid;
11461
11462
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->frame),f))
11463 return qe_invalid;
11464 }
11465
11466 13243 int32_t temp_size=0;
11467
11468 // bool deletets = false;
11469
4/4
✓ Branch 0 taken 5853 times.
✓ Branch 1 taken 1329 times.
✓ Branch 2 taken 5910 times.
✓ Branch 3 taken 151 times.
13243 switch(temp_sub->type)
11470 {
11471 case ssoTEXT:
11472 case ssoTEXTBOX:
11473 case ssoCURRENTITEMTEXT:
11474 case ssoCURRENTITEMCLASSTEXT:
11475 {
11476 word temptempsize;
11477
11478
1/2
✓ Branch 0 taken 1329 times.
✗ Branch 1 not taken.
1329 if(!p_igetw(&temptempsize,f))
11479 {
11480 return qe_invalid;
11481 }
11482
11483 //temptempsize = temp1 + (temp2 << 8);
11484 1329 temp_size = (int32_t)temptempsize;
11485 1329 uint32_t char_length = temp_size+2;
11486
1/2
✓ Branch 0 taken 1329 times.
✗ Branch 1 not taken.
1329 if (char_length > MAX_DP1_LEN)
11487 {
11488 return qe_invalid;
11489 }
11490 1329 tempdp1[char_length - 1] = '\0';
11491
11492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1329 times.
1329 if(temp_size)
11493
1/2
✓ Branch 0 taken 1329 times.
✗ Branch 1 not taken.
1329 if(!pfread(tempdp1,temp_size+1,f))
11494 return qe_invalid;
11495 1329 break;
11496 }
11497
11498 case ssoLIFEMETER:
11499
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11500 temp_sub->d3 = 1;
11501
11502
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&(temp_sub->dp1),f))
11503 return qe_invalid;
11504
11505 151 break;
11506
11507
11508 case ssoCURRENTITEM:
11509
11510
1/2
✓ Branch 0 taken 5853 times.
✗ Branch 1 not taken.
5853 if(s_version < 6)
11511 {
11512 switch(temp_sub->d1)
11513 {
11514 case ssiBOMB:
11515 temp_sub->d1 = itype_bomb;
11516 break;
11517
11518 case ssiSWORD:
11519 temp_sub->d1 = itype_sword;
11520 break;
11521
11522 case ssiSHIELD:
11523 temp_sub->d1 = itype_shield;
11524 break;
11525
11526 case ssiCANDLE:
11527 temp_sub->d1 = itype_candle;
11528 break;
11529
11530 case ssiLETTER:
11531 temp_sub->d1 = itype_letter;
11532 break;
11533
11534 case ssiPOTION:
11535 temp_sub->d1 = itype_potion;
11536 break;
11537
11538 case ssiLETTERPOTION:
11539 temp_sub->d1 = itype_letterpotion;
11540 break;
11541
11542 case ssiBOW:
11543 temp_sub->d1 = itype_bow;
11544 break;
11545
11546 case ssiARROW:
11547 temp_sub->d1 = itype_arrow;
11548 break;
11549
11550 case ssiBOWANDARROW:
11551 temp_sub->d1 = itype_bowandarrow;
11552 break;
11553
11554 case ssiBAIT:
11555 temp_sub->d1 = itype_bait;
11556 break;
11557
11558 case ssiRING:
11559 temp_sub->d1 = itype_ring;
11560 break;
11561
11562 case ssiBRACELET:
11563 temp_sub->d1 = itype_bracelet;
11564 break;
11565
11566 case ssiMAP:
11567 temp_sub->d1 = itype_map;
11568 break;
11569
11570 case ssiCOMPASS:
11571 temp_sub->d1 = itype_compass;
11572 break;
11573
11574 case ssiBOSSKEY:
11575 temp_sub->d1 = itype_bosskey;
11576 break;
11577
11578 case ssiMAGICKEY:
11579 temp_sub->d1 = itype_magickey;
11580 break;
11581
11582 case ssiBRANG:
11583 temp_sub->d1 = itype_brang;
11584 break;
11585
11586 case ssiWAND:
11587 temp_sub->d1 = itype_wand;
11588 break;
11589
11590 case ssiRAFT:
11591 temp_sub->d1 = itype_raft;
11592 break;
11593
11594 case ssiLADDER:
11595 temp_sub->d1 = itype_ladder;
11596 break;
11597
11598 case ssiWHISTLE:
11599 temp_sub->d1 = itype_whistle;
11600 break;
11601
11602 case ssiBOOK:
11603 temp_sub->d1 = itype_book;
11604 break;
11605
11606 case ssiWALLET:
11607 temp_sub->d1 = itype_wallet;
11608 break;
11609
11610 case ssiSBOMB:
11611 temp_sub->d1 = itype_sbomb;
11612 break;
11613
11614 case ssiHCPIECE:
11615 temp_sub->d1 = itype_heartpiece;
11616 break;
11617
11618 case ssiAMULET:
11619 temp_sub->d1 = itype_amulet;
11620 break;
11621
11622 case ssiFLIPPERS:
11623 temp_sub->d1 = itype_flippers;
11624 break;
11625
11626 case ssiHOOKSHOT:
11627 temp_sub->d1 = itype_hookshot;
11628 break;
11629
11630 case ssiLENS:
11631 temp_sub->d1 = itype_lens;
11632 break;
11633
11634 case ssiHAMMER:
11635 temp_sub->d1 = itype_hammer;
11636 break;
11637
11638 case ssiBOOTS:
11639 temp_sub->d1 = itype_boots;
11640 break;
11641
11642 case ssiDIVINEFIRE:
11643 temp_sub->d1 = itype_divinefire;
11644 break;
11645
11646 case ssiDIVINEESCAPE:
11647 temp_sub->d1 = itype_divineescape;
11648 break;
11649
11650 case ssiDIVINEPROTECTION:
11651 temp_sub->d1 = itype_divineprotection;
11652 break;
11653
11654 case ssiQUIVER:
11655 temp_sub->d1 = itype_quiver;
11656 break;
11657
11658 case ssiBOMBBAG:
11659 temp_sub->d1 = itype_bombbag;
11660 break;
11661
11662 case ssiCBYRNA:
11663 temp_sub->d1 = itype_cbyrna;
11664 break;
11665
11666 case ssiROCS:
11667 temp_sub->d1 = itype_rocs;
11668 break;
11669
11670 case ssiHOVERBOOTS:
11671 temp_sub->d1 = itype_hoverboots;
11672 break;
11673
11674 case ssiSPINSCROLL:
11675 temp_sub->d1 = itype_spinscroll;
11676 break;
11677
11678 case ssiCROSSSCROLL:
11679 temp_sub->d1 = itype_crossscroll;
11680 break;
11681
11682 case ssiQUAKESCROLL:
11683 temp_sub->d1 = itype_quakescroll;
11684 break;
11685
11686 case ssiWHISPRING:
11687 temp_sub->d1 = itype_whispring;
11688 break;
11689
11690 case ssiCHARGERING:
11691 temp_sub->d1 = itype_chargering;
11692 break;
11693
11694 case ssiPERILSCROLL:
11695 temp_sub->d1 = itype_perilscroll;
11696 break;
11697
11698 case ssiWEALTHMEDAL:
11699 temp_sub->d1 = itype_wealthmedal;
11700 break;
11701
11702 case ssiHEARTRING:
11703 temp_sub->d1 = itype_heartring;
11704 break;
11705
11706 case ssiMAGICRING:
11707 temp_sub->d1 = itype_magicring;
11708 break;
11709
11710 case ssiSPINSCROLL2:
11711 temp_sub->d1 = itype_spinscroll2;
11712 break;
11713
11714 case ssiQUAKESCROLL2:
11715 temp_sub->d1 = itype_quakescroll2;
11716 break;
11717
11718 case ssiAGONY:
11719 temp_sub->d1 = itype_agony;
11720 break;
11721
11722 case ssiSTOMPBOOTS:
11723 temp_sub->d1 = itype_stompboots;
11724 break;
11725
11726 case ssiWHIMSICALRING:
11727 temp_sub->d1 = itype_whimsicalring;
11728 break;
11729
11730 case ssiPERILRING:
11731 temp_sub->d1 = itype_perilring;
11732 break;
11733
11734 default:
11735 temp_sub->d1 += itype_custom1 - ssiMAX;
11736 }
11737 }
11738
11739 //fall-through
11740 default:
11741
1/2
✓ Branch 0 taken 11763 times.
✗ Branch 1 not taken.
11763 if(!p_getc(&(temp_sub->dp1),f))
11742 return qe_invalid;
11743
11744 11763 break;
11745 }
11746
11747
2/2
✓ Branch 0 taken 4559 times.
✓ Branch 1 taken 8684 times.
13243 if(s_version < 7)
11748 {
11749
3/3
✓ Branch 0 taken 8025 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 432 times.
8684 switch(temp_sub->type)
11750 {
11751 case ssoMAGICGAUGE:
11752 {
11753
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 192 times.
227 if(!temp_sub->d9)
11754 192 temp_sub->d9 = -1; //-1 now represents 'always'
11755 227 break;
11756 }
11757 case ssoLIFEGAUGE:
11758 432 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11759 432 break;
11760 }
11761 8684 }
11762
11763
3/3
✓ Branch 0 taken 1329 times.
✓ Branch 1 taken 11457 times.
✓ Branch 2 taken 457 times.
13243 switch(temp_sub->type)
11764 {
11765 case ssoTEXT:
11766 case ssoTEXTBOX:
11767 case ssoCURRENTITEMTEXT:
11768 case ssoCURRENTITEMCLASSTEXT:
11769
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1329 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1329 if(g->objects[j].dp1 != NULL) delete[](char *)g->objects[j].dp1;
11770
11771 1329 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11772 1329 g->objects[j].dp1 = new char[temp_size+2];
11773 1329 strcpy((char*)g->objects[j].dp1,tempdp1);
11774 1329 break;
11775
11776 case ssoCOUNTER:
11777
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(s_version<3)
11778 {
11779 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11780 temp_sub->d8=0;
11781 }
11782
11783 default:
11784 11914 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11785 11914 break;
11786 }
11787
11788 13243 g->name[0] = '\0';
11789 13243 strncat(g->name, tempname, 64 - 1);
11790 13243 g->ss_type = temp_ss;
11791 13243 }
11792
11793
2/2
✓ Branch 0 taken 2804805 times.
✓ Branch 1 taken 11008 times.
2815813 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11794 {
11795 //clear all unused object in this subscreen -DD
11796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2804805 times.
2804805 switch(g->objects[j].type)
11797 {
11798 case ssoTEXT:
11799 case ssoTEXTBOX:
11800 case ssoCURRENTITEMTEXT:
11801 case ssoCURRENTITEMCLASSTEXT:
11802 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11803
11804 //fall through
11805 default:
11806 2804805 memset(&g->objects[j],0,sizeof(subscreen_object));
11807 2804805 break;
11808 }
11809 2804805 }
11810
11811 11008 return 0;
11812 11008 }
11813
11814 112 int32_t readsubscreens(PACKFILE *f)
11815 {
11816 word s_version, s_cversion;
11817 dword dummy;
11818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(!p_igetw(&s_version,f))
11819 return qe_invalid;
11820 112 FFCore.quest_format[vSubscreen] = s_version;
11821
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetw(&s_cversion,f))
11822 return qe_invalid;
11823
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetl(&dummy,f)) //section size
11824 return qe_invalid;
11825
11826
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 26 times.
112 if(s_version < 8)
11827 86 return read_old_subscreens(f,s_version);
11828
11829 26 subscreens_active.clear();
11830 26 subscreens_passive.clear();
11831 26 subscreens_overlay.clear();
11832
11833 byte sz;
11834
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(!p_getc(&sz,f))
11835 return qe_invalid;
11836
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 26 times.
106 for(byte q = 0; q < sz; ++q)
11837 {
11838 80 ZCSubscreen& tmp = subscreens_active.emplace_back();
11839
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if (auto ret = tmp.read(f, s_version))
11840 return ret;
11841 80 }
11842
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(!p_getc(&sz,f))
11843 return qe_invalid;
11844
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 26 times.
130 for(byte q = 0; q < sz; ++q)
11845 {
11846 104 ZCSubscreen& tmp = subscreens_passive.emplace_back();
11847
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if (auto ret = tmp.read(f, s_version))
11848 return ret;
11849 104 }
11850
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(!p_getc(&sz,f))
11851 return qe_invalid;
11852
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 26 times.
42 for(byte q = 0; q < sz; ++q)
11853 {
11854 16 ZCSubscreen& tmp = subscreens_overlay.emplace_back();
11855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (auto ret = tmp.read(f, s_version))
11856 return ret;
11857 16 }
11858 26 return 0;
11859 112 }
11860
11861 void reset_subscreen(subscreen_group *tempss)
11862 {
11863 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11864 {
11865 switch(tempss->objects[i].type)
11866 {
11867 case ssoTEXT:
11868 case ssoTEXTBOX:
11869 case ssoCURRENTITEMTEXT:
11870 case ssoCURRENTITEMCLASSTEXT:
11871 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11872
11873 //fall through
11874 default:
11875 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11876 break;
11877 }
11878 }
11879 }
11880
11881 31 void reset_subscreens()
11882 {
11883 31 subscreens_active.clear();
11884 31 subscreens_passive.clear();
11885 31 subscreens_overlay.clear();
11886 31 }
11887
11888 31 int32_t setupsubscreens()
11889 {
11890 31 reset_subscreens();
11891 //return 0;
11892
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 62 times.
93 for(int q = 0; q < 2; ++q)
11893 {
11894 62 subscreens_active.emplace_back();
11895 62 subscreens_passive.emplace_back();
11896 62 }
11897 31 int32_t tempsubscreen=zinit.subscreen;
11898
11899
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(tempsubscreen>=ssdtMAX)
11900 tempsubscreen=0;
11901
11902
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
31 switch(tempsubscreen)
11903 {
11904 case ssdtOLD:
11905 case ssdtNEWSUBSCR:
11906 case ssdtREV2:
11907 case ssdtBSZELDA:
11908 case ssdtBSZELDAMODIFIED:
11909 case ssdtBSZELDAENHANCED:
11910 case ssdtBSZELDACOMPLETE:
11911 {
11912 31 subscreens_active[0].load_old(default_subscreen_active[tempsubscreen][0]);
11913 31 subscreens_active[0].sub_type=sstACTIVE;
11914 31 subscreens_active[0].name = "Active Subscreen (Triforce)";
11915 31 subscreens_active[1].load_old(default_subscreen_active[tempsubscreen][1]);
11916 31 subscreens_active[1].sub_type=sstACTIVE;
11917 31 subscreens_active[1].name = "Active Subscreen (Dungeon Map)";
11918 31 subscreens_passive[0].load_old(default_subscreen_passive[tempsubscreen][0]);
11919 31 subscreens_passive[0].sub_type=sstPASSIVE;
11920 31 subscreens_passive[0].name = "Passive Subscreen (Magic)";
11921 31 subscreens_passive[1].load_old(default_subscreen_passive[tempsubscreen][1]);
11922 31 subscreens_passive[1].sub_type=sstPASSIVE;
11923 31 subscreens_passive[1].name = "Passive Subscreen (No Magic)";
11924 31 break;
11925 }
11926
11927 case ssdtZ3:
11928 {
11929 subscreens_active[0].load_old(z3_active_a);
11930 subscreens_active[0].sub_type=sstACTIVE;
11931 subscreens_active[1].load_old(z3_active_ab);
11932 subscreens_active[1].sub_type=sstACTIVE;
11933 subscreens_passive[0].load_old(z3_passive_a);
11934 subscreens_passive[0].sub_type=sstPASSIVE;
11935 subscreens_passive[1].load_old(z3_passive_ab);
11936 subscreens_passive[1].sub_type=sstPASSIVE;
11937 break;
11938 }
11939 }
11940
11941 31 return 0;
11942 }
11943
11944 extern script_data *ffscripts[NUMSCRIPTFFC];
11945 extern script_data *itemscripts[NUMSCRIPTITEM];
11946 extern script_data *guyscripts[NUMSCRIPTGUYS];
11947 extern script_data *wpnscripts[NUMSCRIPTWEAPONS];
11948 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
11949 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
11950 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
11951 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
11952 extern script_data *playerscripts[NUMSCRIPTPLAYER];
11953 extern script_data *screenscripts[NUMSCRIPTSCREEN];
11954 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
11955 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
11956 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
11957 extern script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
11958 //script_data *wpnscripts[NUMSCRIPTWEAPONS]; //used only for old data
11959
11960
11961
11962 102 int32_t readffscript(PACKFILE *f, zquestheader *Header)
11963 {
11964 int32_t dummy;
11965 102 word s_version=0, s_cversion=0, zmeta_version=0;
11966 102 byte numscripts=0;
11967 102 numscripts=numscripts; //to avoid unused variables warnings
11968 int32_t ret;
11969
11970 //section version info
11971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(!p_igetw(&s_version,f))
11972 {
11973 return qe_invalid;
11974 }
11975
11976 102 FFCore.quest_format[vFFScript] = s_version;
11977
11978
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&s_cversion,f))
11979 {
11980 return qe_invalid;
11981 }
11982
11983
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 35 times.
102 if(s_version >= 18)
11984 {
11985
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetw(&zmeta_version,f))
11986 {
11987 return qe_invalid;
11988 }
11989 35 }
11990
11991 //al_trace("Scripts version %d\n", s_version);
11992 //section size
11993
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetl(&dummy,f))
11994 {
11995 return qe_invalid;
11996 }
11997
11998 //ZScriptVersion::setVersion(s_version); ~this ideally, but there's no ZC/ZQuest defines...
11999 102 setZScriptVersion(s_version); //Lumped in zelda.cpp and in zquest.cpp as zquest can't link ZScriptVersion
12000 //miscQdata *the_misc;
12001
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 77 times.
102 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12002 102 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12003
12004 //finally... section data
12005
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 62 times.
57446 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12006 {
12007 57344 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
12008
12009
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if (ret)
12010 {
12011 return qe_invalid;
12012 }
12013 57344 }
12014
12015 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12016 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12017 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12018 * there was a version bump a week before a change that broke stuff.
12019 */
12020
7/8
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 35 times.
✓ Branch 5 taken 35 times.
✓ Branch 6 taken 35 times.
✓ Branch 7 taken 35 times.
62 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
12021 {
12022 97 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
12023 97 }
12024
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 77 times.
112 if(s_version < 19)
12025 {
12026 77 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
12027 77 }
12028
12029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(s_version > 1)
12030 {
12031
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 112 times.
28784 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12032 {
12033 28672 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
12034
12035
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if (ret)
12036 {
12037 return qe_invalid;
12038 }
12039 28672 }
12040
12041
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 112 times.
28784 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12042 {
12043 28672 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12044
12045
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if (ret)
12046 {
12047 return qe_invalid;
12048 }
12049 28672 }
12050
12051
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 112 times.
28784 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12052 {
12053 28672 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &wpnscripts[i], zmeta_version);
12054
12055
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if (ret)
12056 {
12057 return qe_invalid;
12058 }
12059 28672 }
12060
12061
12062
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 112 times.
28784 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12063 {
12064 28672 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12065
12066
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if (ret)
12067 {
12068 return qe_invalid;
12069 }
12070 28672 }
12071
12072
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 77 times.
112 if(s_version > 16)
12073 {
12074
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 35 times.
315 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12075 {
12076 280 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12077
12078
1/2
✓ Branch 0 taken 280 times.
✗ Branch 1 not taken.
280 if (ret)
12079 {
12080 return qe_invalid;
12081 }
12082 280 }
12083 35 }
12084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 else if(s_version > 13)
12085 {
12086 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12087 {
12088 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12089
12090 if (ret)
12091 {
12092 return qe_invalid;
12093 }
12094 }
12095
12096 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12097 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12098
12099 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12100 }
12101
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 else if(s_version > 4)
12102 {
12103
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12104 {
12105 308 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12106
12107
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if (ret)
12108 {
12109 return qe_invalid;
12110 }
12111 308 }
12112
12113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12114
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12115
12116
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12117
12118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12119
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12120
12121
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12122
12123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12124
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_F6];
12125
12126
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12127
12128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12129
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12130
12131
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12132 77 }
12133 else
12134 {
12135 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12136 {
12137 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12138
12139 if (ret)
12140 {
12141 return qe_invalid;
12142 }
12143 }
12144
12145 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12146 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12147
12148 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data();
12149
12150 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12151 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12152
12153 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12154
12155 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12156 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12157
12158 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12159
12160 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12161 delete globalscripts[GLOBAL_SCRIPT_F6];
12162
12163 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12164
12165 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12166 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12167
12168 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12169 }
12170
12171
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 77 times.
112 if(s_version > 10) //expanded the number of Player scripts to 5.
12172 {
12173
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 35 times.
210 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12174 {
12175 175 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12176
12177
1/2
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
175 if (ret)
12178 {
12179 return qe_invalid;
12180 }
12181 175 }
12182 35 }
12183 else
12184 {
12185
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 77 times.
308 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12186 {
12187 231 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12188
12189
1/2
✓ Branch 0 taken 231 times.
✗ Branch 1 not taken.
231 if (ret)
12190 {
12191 return qe_invalid;
12192 }
12193 231 }
12194
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(playerscripts[3] != NULL)
12195
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete playerscripts[3];
12196
12197
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 playerscripts[3] = new script_data();
12198
12199
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(playerscripts[4] != NULL)
12200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 delete playerscripts[4];
12201
12202
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 playerscripts[4] = new script_data();
12203 }
12204
3/4
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
112 if(s_version > 8 && s_version < 10)
12205 {
12206
12207 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12208 {
12209 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12210
12211 if (ret)
12212 {
12213 return qe_invalid;
12214 }
12215 }
12216 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12217 {
12218 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12219
12220 if (ret)
12221 {
12222 return qe_invalid;
12223 }
12224 }
12225
12226 }
12227
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 35 times.
112 if(s_version >= 10)
12228 {
12229
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 35 times.
8995 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12230 {
12231 8960 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12232
12233
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if (ret)
12234 {
12235 return qe_invalid;
12236 }
12237 8960 }
12238
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 35 times.
8995 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12239 {
12240 8960 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12241
12242
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if (ret)
12243 {
12244 return qe_invalid;
12245 }
12246 8960 }
12247
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 35 times.
8995 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12248 {
12249 8960 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12250
12251
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if (ret)
12252 {
12253 return qe_invalid;
12254 }
12255 8960 }
12256
12257 35 }
12258
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 35 times.
112 if(s_version >=12)
12259 {
12260
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 35 times.
8995 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12261 {
12262 8960 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12263
12264
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if (ret)
12265 {
12266 return qe_invalid;
12267 }
12268 8960 }
12269 35 }
12270
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 35 times.
112 if(s_version >=15)
12271 {
12272
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 35 times.
17955 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12273 {
12274 17920 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12275
12276
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if (ret)
12277 {
12278 return qe_invalid;
12279 }
12280 17920 }
12281 35 }
12282
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 35 times.
112 if(s_version >19)
12283 {
12284 35 word numgenscripts = NUMSCRIPTSGENERIC;
12285
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetw(&numgenscripts,f))
12286 {
12287 return qe_invalid;
12288 }
12289
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 35 times.
17955 for(int32_t i = 0; i < numgenscripts; i++)
12290 {
12291 17920 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12292
12293
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if (ret)
12294 {
12295 return qe_invalid;
12296 }
12297 17920 }
12298 35 }
12299
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 8 times.
112 if(s_version >21)
12300 {
12301 8 word numsubscripts = NUMSCRIPTSSUBSCREEN;
12302
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetw(&numsubscripts,f))
12303 {
12304 return qe_invalid;
12305 }
12306
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 8 times.
2056 for(int32_t i = 0; i < numsubscripts; i++)
12307 {
12308 2048 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &subscreenscripts[i], zmeta_version);
12309
12310
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 if (ret)
12311 {
12312 return qe_invalid;
12313 }
12314 2048 }
12315 8 }
12316 112 }
12317
12318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(s_version > 2)
12319 {
12320 int32_t bufsize;
12321 112 p_igetl(&bufsize, f);
12322
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
112 if (bufsize < 0 || bufsize > 1024*1024*10)
12323 {
12324 // God help anyone storing more than 10MB of code in the script buffer.
12325 return qe_invalid;
12326 }
12327 112 char * buf = new char[bufsize+1];
12328 112 pfread(buf, bufsize, f);
12329 112 buf[bufsize]=0;
12330
12331
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 zScript = string(buf);
12332
12333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 delete[] buf;
12334 word numffcbindings;
12335 112 p_igetw(&numffcbindings, f);
12336
12337
2/2
✓ Branch 0 taken 1570 times.
✓ Branch 1 taken 112 times.
1682 for(int32_t i=0; i<numffcbindings; i++)
12338 {
12339 word id;
12340 1570 p_igetw(&id, f);
12341 1570 p_igetl(&bufsize, f);
12342
2/4
✓ Branch 0 taken 1570 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1570 times.
1570 if (bufsize < 0 || bufsize > 1024)
12343 return qe_invalid;
12344 1570 buf = new char[bufsize+1];
12345 1570 pfread(buf, bufsize, f);
12346 1570 buf[bufsize]=0;
12347
12348 //fix for buggy older saved quests -DD
12349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1570 times.
1570 if(id < NUMSCRIPTFFC-1)
12350 1570 ffcmap[id].scriptname = buf;
12351
12352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1570 times.
1570 delete[] buf;
12353 1570 }
12354
12355 word numglobalbindings;
12356 112 p_igetw(&numglobalbindings, f);
12357
12358
2/2
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 112 times.
547 for(int32_t i=0; i<numglobalbindings; i++)
12359 {
12360 word id;
12361 435 p_igetw(&id, f);
12362 435 p_igetl(&bufsize, f);
12363
2/4
✓ Branch 0 taken 435 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 435 times.
435 if (bufsize < 0 || bufsize > 1024)
12364 return qe_invalid;
12365 435 buf = new char[bufsize+1];
12366 435 pfread(buf, bufsize, f);
12367 435 buf[bufsize]=0;
12368
12369 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12370 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12371 // Ignore these. -DD
12372
3/4
✓ Branch 0 taken 435 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 159 times.
✓ Branch 3 taken 276 times.
435 if(id >= 0 && id < NUMSCRIPTGLOBAL)
12373 {
12374 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12375
1/2
✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
276 if(strcmp(buf,"~Continue") == 0)
12376 {
12377 globalmap[id].scriptname = "";
12378
12379 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12380 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12381 }
12382 else
12383 {
12384 276 globalmap[id].scriptname = buf;
12385 }
12386 276 }
12387
12388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 435 times.
435 delete[] buf;
12389 435 }
12390
12391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(s_version > 3)
12392 {
12393 word numitembindings;
12394 112 p_igetw(&numitembindings, f);
12395
12396
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 112 times.
210 for(int32_t i=0; i<numitembindings; i++)
12397 {
12398 word id;
12399 98 p_igetw(&id, f);
12400 98 p_igetl(&bufsize, f);
12401
2/4
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
98 if (bufsize < 0 || bufsize > 1024)
12402 return qe_invalid;
12403 98 buf = new char[bufsize+1];
12404 98 pfread(buf, bufsize, f);
12405 98 buf[bufsize]=0;
12406
12407 //fix this too
12408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 if(id <NUMSCRIPTITEM-1)
12409 98 itemmap[id].scriptname = buf;
12410
12411
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 delete[] buf;
12412 98 }
12413 112 }
12414 //(v9+)
12415
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 35 times.
112 if(s_version > 8)
12416 {
12417 //npc scripts
12418 word numnpcbindings;
12419 35 p_igetw(&numnpcbindings, f);
12420
12421
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 35 times.
47 for(int32_t i=0; i<numnpcbindings; i++)
12422 {
12423 word id;
12424 12 p_igetw(&id, f);
12425 12 p_igetl(&bufsize, f);
12426
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if (bufsize < 0 || bufsize > 1024)
12427 return qe_invalid;
12428 12 buf = new char[bufsize+1];
12429 12 pfread(buf, bufsize, f);
12430 12 buf[bufsize]=0;
12431
12432 //fix this too
12433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(id <NUMSCRIPTGUYS-1)
12434 12 npcmap[id].scriptname = buf;
12435
12436
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 delete[] buf;
12437 12 }
12438 //lweapon
12439 word numlwpnbindings;
12440 35 p_igetw(&numlwpnbindings, f);
12441
12442
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 35 times.
77 for(int32_t i=0; i<numlwpnbindings; i++)
12443 {
12444 word id;
12445 42 p_igetw(&id, f);
12446 42 p_igetl(&bufsize, f);
12447
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
42 if (bufsize < 0 || bufsize > 1024)
12448 return qe_invalid;
12449 42 buf = new char[bufsize+1];
12450 42 pfread(buf, bufsize, f);
12451 42 buf[bufsize]=0;
12452
12453 //fix this too
12454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(id <NUMSCRIPTWEAPONS-1)
12455 42 lwpnmap[id].scriptname = buf;
12456
12457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 delete[] buf;
12458 42 }
12459 //eweapon
12460 word numewpnbindings;
12461 35 p_igetw(&numewpnbindings, f);
12462
12463
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 35 times.
98 for(int32_t i=0; i<numewpnbindings; i++)
12464 {
12465 word id;
12466 63 p_igetw(&id, f);
12467 63 p_igetl(&bufsize, f);
12468
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
63 if (bufsize < 0 || bufsize > 1024)
12469 return qe_invalid;
12470 63 buf = new char[bufsize+1];
12471 63 pfread(buf, bufsize, f);
12472 63 buf[bufsize]=0;
12473
12474 //fix this too
12475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(id <NUMSCRIPTWEAPONS-1)
12476 63 ewpnmap[id].scriptname = buf;
12477
12478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 delete[] buf;
12479 63 }
12480 //hero
12481 word numherobindings;
12482 35 p_igetw(&numherobindings, f);
12483
12484
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 35 times.
40 for(int32_t i=0; i<numherobindings; i++)
12485 {
12486 word id;
12487 5 p_igetw(&id, f);
12488 5 p_igetl(&bufsize, f);
12489
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if (bufsize < 0 || bufsize > 1024)
12490 return qe_invalid;
12491 5 buf = new char[bufsize+1];
12492 5 pfread(buf, bufsize, f);
12493 5 buf[bufsize]=0;
12494
12495 //fix this too
12496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(id <NUMSCRIPTPLAYER-1)
12497 5 playermap[id].scriptname = buf;
12498
12499
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 delete[] buf;
12500 5 }
12501 //dmaps
12502 word numdmapbindings;
12503 35 p_igetw(&numdmapbindings, f);
12504
12505
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 35 times.
67 for(int32_t i=0; i<numdmapbindings; i++)
12506 {
12507 word id;
12508 32 p_igetw(&id, f);
12509 32 p_igetl(&bufsize, f);
12510
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
32 if (bufsize < 0 || bufsize > 1024)
12511 return qe_invalid;
12512 32 buf = new char[bufsize+1];
12513 32 pfread(buf, bufsize, f);
12514 32 buf[bufsize]=0;
12515
12516 //fix this too
12517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(id <NUMSCRIPTSDMAP-1)
12518 32 dmapmap[id].scriptname = buf;
12519
12520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 delete[] buf;
12521 32 }
12522 //screen
12523 word numscreenbindings;
12524 35 p_igetw(&numscreenbindings, f);
12525
12526
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 35 times.
71 for(int32_t i=0; i<numscreenbindings; i++)
12527 {
12528 word id;
12529 36 p_igetw(&id, f);
12530 36 p_igetl(&bufsize, f);
12531
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if (bufsize < 0 || bufsize > 1024)
12532 return qe_invalid;
12533 36 buf = new char[bufsize+1];
12534 36 pfread(buf, bufsize, f);
12535 36 buf[bufsize]=0;
12536
12537 //fix this too
12538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(id <NUMSCRIPTSDMAP-1)
12539 36 screenmap[id].scriptname = buf;
12540
12541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 delete[] buf;
12542 36 }
12543 35 }
12544
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 35 times.
112 if(s_version > 11)
12545 {
12546 word numspritebindings;
12547 35 p_igetw(&numspritebindings, f);
12548
12549
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 35 times.
45 for(int32_t i=0; i<numspritebindings; i++)
12550 {
12551 word id;
12552 10 p_igetw(&id, f);
12553 10 p_igetl(&bufsize, f);
12554
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 if (bufsize < 0 || bufsize > 1024)
12555 return qe_invalid;
12556 10 buf = new char[bufsize+1];
12557 10 pfread(buf, bufsize, f);
12558 10 buf[bufsize]=0;
12559
12560 //fix this too
12561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(id <NUMSCRIPTSDMAP-1)
12562 10 itemspritemap[id].scriptname = buf;
12563
12564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 delete[] buf;
12565 10 }
12566 35 }
12567
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 35 times.
112 if(s_version >= 15)
12568 {
12569 word numcombobindings;
12570 35 p_igetw(&numcombobindings, f);
12571
12572
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 35 times.
58 for(int32_t i=0; i<numcombobindings; i++)
12573 {
12574 word id;
12575 23 p_igetw(&id, f);
12576 23 p_igetl(&bufsize, f);
12577
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if (bufsize < 0 || bufsize > 1024)
12578 return qe_invalid;
12579 23 buf = new char[bufsize+1];
12580 23 pfread(buf, bufsize, f);
12581 23 buf[bufsize]=0;
12582
12583 //fix this too
12584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(id <NUMSCRIPTSCOMBODATA-1)
12585 23 comboscriptmap[id].scriptname = buf;
12586
12587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 delete[] buf;
12588 23 }
12589 35 }
12590
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 35 times.
112 if(s_version > 19)
12591 {
12592 word numgenericbindings;
12593 35 p_igetw(&numgenericbindings, f);
12594
12595
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 35 times.
48 for(int32_t i=0; i<numgenericbindings; i++)
12596 {
12597 word id;
12598 13 p_igetw(&id, f);
12599 13 p_igetl(&bufsize, f);
12600
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if (bufsize < 0 || bufsize > 1024)
12601 return qe_invalid;
12602 13 buf = new char[bufsize+1];
12603 13 pfread(buf, bufsize, f);
12604 13 buf[bufsize]=0;
12605
12606 //fix this too
12607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(id <NUMSCRIPTSGENERIC-1)
12608 13 genericmap[id].scriptname = buf;
12609
12610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 delete[] buf;
12611 13 }
12612 35 }
12613
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 8 times.
112 if(s_version > 21)
12614 {
12615 word numsubscreenbindings;
12616 8 p_igetw(&numsubscreenbindings, f);
12617
12618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 for(int32_t i=0; i<numsubscreenbindings; i++)
12619 {
12620 word id;
12621 p_igetw(&id, f);
12622 p_igetl(&bufsize, f);
12623 if (bufsize < 0 || bufsize > 1024)
12624 return qe_invalid;
12625 buf = new char[bufsize+1];
12626 pfread(buf, bufsize, f);
12627 buf[bufsize]=0;
12628
12629 //fix this too
12630 if(id <NUMSCRIPTSSUBSCREEN-1)
12631 subscreenmap[id].scriptname = buf;
12632
12633 delete[] buf;
12634 }
12635 8 }
12636 112 }
12637
12638 112 return 0;
12639 112 }
12640
12641 128 void reset_scripts()
12642 {
12643 #ifdef IS_PLAYER
12644 // We can't modify the script data while jit threads are possibly compiling them.
12645 void jit_shutdown();
12646 128 jit_shutdown();
12647 #endif
12648
12649 128 next_script_data_debug_id = 0;
12650
12651
2/2
✓ Branch 0 taken 65536 times.
✓ Branch 1 taken 128 times.
65664 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12652 {
12653
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 58880 times.
65536 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12654
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 else genericscripts[i] = new script_data();
12655 65536 }
12656
12657
2/2
✓ Branch 0 taken 65536 times.
✓ Branch 1 taken 128 times.
65664 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12658 {
12659
1/2
✓ Branch 0 taken 65536 times.
✗ Branch 1 not taken.
65536 if(ffscripts[i]!=NULL)
12660 {
12661 65536 ffscripts[i]->disable();
12662 65536 }
12663 else
12664 {
12665 ffscripts[i] = new script_data();
12666 }
12667 65536 }
12668
12669
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12670 {
12671
1/2
✓ Branch 0 taken 32768 times.
✗ Branch 1 not taken.
32768 if(itemscripts[i]!=NULL)
12672 {
12673 32768 itemscripts[i]->disable();
12674 32768 }
12675 else
12676 {
12677 itemscripts[i] = new script_data();
12678 }
12679 32768 }
12680
12681
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12682 {
12683
1/2
✓ Branch 0 taken 32768 times.
✗ Branch 1 not taken.
32768 if(guyscripts[i]!=NULL)
12684 {
12685 32768 guyscripts[i]->disable();
12686 32768 }
12687 else
12688 {
12689 guyscripts[i] = new script_data();
12690 }
12691 32768 }
12692
12693
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12694 {
12695
1/2
✓ Branch 0 taken 32768 times.
✗ Branch 1 not taken.
32768 if(wpnscripts[i]!=NULL)
12696 {
12697 32768 wpnscripts[i]->disable();
12698 32768 }
12699 else
12700 {
12701 wpnscripts[i] = new script_data();
12702 }
12703 32768 }
12704
12705
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12706 {
12707
1/2
✓ Branch 0 taken 32768 times.
✗ Branch 1 not taken.
32768 if(screenscripts[i]!=NULL)
12708 {
12709 32768 screenscripts[i]->disable();
12710 32768 }
12711 else
12712 {
12713 screenscripts[i] = new script_data();
12714 }
12715 32768 }
12716
12717
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 128 times.
1152 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12718 {
12719
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(globalscripts[i]!=NULL)
12720 {
12721 1024 globalscripts[i]->disable();
12722 1024 }
12723 else
12724 {
12725 globalscripts[i] = new script_data();
12726 }
12727 1024 }
12728
12729
2/2
✓ Branch 0 taken 640 times.
✓ Branch 1 taken 128 times.
768 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
12730 {
12731
1/2
✓ Branch 0 taken 640 times.
✗ Branch 1 not taken.
640 if(playerscripts[i]!=NULL)
12732 {
12733 640 playerscripts[i]->disable();
12734 640 }
12735 else
12736 {
12737 playerscripts[i] = new script_data();
12738 }
12739 640 }
12740
12741
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12742 {
12743
1/2
✓ Branch 0 taken 32768 times.
✗ Branch 1 not taken.
32768 if(lwpnscripts[i]!=NULL)
12744 {
12745 32768 lwpnscripts[i]->disable();
12746 32768 }
12747 else
12748 {
12749 lwpnscripts[i] = new script_data();
12750 }
12751 32768 }
12752
12753
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12754 {
12755
1/2
✓ Branch 0 taken 32768 times.
✗ Branch 1 not taken.
32768 if(ewpnscripts[i]!=NULL)
12756 {
12757 32768 ewpnscripts[i]->disable();
12758 32768 }
12759 else
12760 {
12761 ewpnscripts[i] = new script_data();
12762 }
12763 32768 }
12764
12765
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12766 {
12767
1/2
✓ Branch 0 taken 32768 times.
✗ Branch 1 not taken.
32768 if(dmapscripts[i]!=NULL)
12768 {
12769 32768 dmapscripts[i]->disable();
12770 32768 }
12771 else
12772 {
12773 dmapscripts[i] = new script_data();
12774 }
12775 32768 }
12776
12777
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12778 {
12779
1/2
✓ Branch 0 taken 32768 times.
✗ Branch 1 not taken.
32768 if(itemspritescripts[i]!=NULL)
12780 {
12781 32768 itemspritescripts[i]->disable();
12782 32768 }
12783 else
12784 {
12785 itemspritescripts[i] = new script_data();
12786 }
12787 32768 }
12788
12789
2/2
✓ Branch 0 taken 65536 times.
✓ Branch 1 taken 128 times.
65664 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12790 {
12791
1/2
✓ Branch 0 taken 65536 times.
✗ Branch 1 not taken.
65536 if(comboscripts[i]!=NULL)
12792 {
12793 65536 comboscripts[i]->disable();
12794 65536 }
12795 else
12796 {
12797 comboscripts[i] = new script_data();
12798 }
12799 65536 }
12800
12801
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
12802 {
12803
1/2
✓ Branch 0 taken 32768 times.
✗ Branch 1 not taken.
32768 if(subscreenscripts[i]!=NULL)
12804 {
12805 32768 subscreenscripts[i]->disable();
12806 32768 }
12807 else
12808 {
12809 subscreenscripts[i] = new script_data();
12810 }
12811 32768 }
12812 128 }
12813
12814 extern script_command command_list[];
12815 246754 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, word , script_data **script, word zmeta_version)
12816 {
12817 //Please also update loadquest() when modifying this method -DD
12818 246754 char b33[34] = {0};
12819 246754 b33[33] = 0;
12820 246754 ffscript temp_script;
12821 246754 int32_t num_commands=1000;
12822
12823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 246754 times.
246754 if(s_version>=2)
12824 {
12825
2/4
✓ Branch 0 taken 246754 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246754 times.
✗ Branch 3 not taken.
246754 if(!p_igetl(&num_commands,f))
12826 {
12827 return qe_invalid;
12828 }
12829 246754 }
12830
12831 #ifdef ZC_FUZZ
12832 const int32_t command_limit = 300000;
12833 #else
12834 246754 const int32_t command_limit = 10000000;
12835 #endif
12836
2/4
✓ Branch 0 taken 246754 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246754 times.
✗ Branch 3 not taken.
246754 if (num_commands < 0 || num_commands > command_limit)
12837 {
12838 return qe_invalid;
12839 }
12840
12841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 246754 times.
246754 if((*script) != NULL)
12842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 246754 times.
246754 delete (*script);
12843
2/4
✓ Branch 0 taken 246754 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246754 times.
✗ Branch 3 not taken.
246754 (*script) = new script_data(num_commands);
12844
12845
2/2
✓ Branch 0 taken 127943 times.
✓ Branch 1 taken 118811 times.
246754 if(s_version >= 16)
12846 {
12847
1/2
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
127943 zasm_meta temp_meta;
12848
12849
2/4
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127943 times.
✗ Branch 3 not taken.
127943 if(!p_igetw(&(temp_meta.zasm_v),f))
12850 {
12851 return qe_invalid;
12852 }
12853
12854
2/4
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127943 times.
✗ Branch 3 not taken.
127943 if(!p_igetw(&(temp_meta.meta_v),f))
12855 {
12856 return qe_invalid;
12857 }
12858
12859
2/4
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127943 times.
✗ Branch 3 not taken.
127943 if(!p_igetw(&(temp_meta.ffscript_v),f))
12860 {
12861 return qe_invalid;
12862 }
12863
12864
2/4
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127943 times.
✗ Branch 3 not taken.
127943 if(!p_getc(&(temp_meta.script_type),f))
12865 {
12866 return qe_invalid;
12867 }
12868
12869
2/2
✓ Branch 0 taken 1023544 times.
✓ Branch 1 taken 127943 times.
1151487 for(int32_t q = 0; q < 8; ++q)
12870 {
12871
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 965992 times.
1023544 if(zmeta_version < 3)
12872 {
12873
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 1899216 times.
1956768 for(int32_t c = 0; c < 33; ++c)
12874 {
12875
2/4
✓ Branch 0 taken 1899216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1899216 times.
✗ Branch 3 not taken.
1899216 if(!p_getc(&(b33[c]),f))
12876 {
12877 return qe_invalid;
12878 }
12879 1899216 }
12880
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.run_idens[q].assign(b33);
12881 57552 }
12882 else
12883 {
12884
2/4
✓ Branch 0 taken 965992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965992 times.
✗ Branch 3 not taken.
965992 if(!p_getcstr(&temp_meta.run_idens[q],f))
12885 {
12886 return qe_invalid;
12887 }
12888 }
12889 1023544 }
12890
12891
2/2
✓ Branch 0 taken 127943 times.
✓ Branch 1 taken 1023544 times.
1151487 for(int32_t q = 0; q < 8; ++q)
12892 {
12893
2/4
✓ Branch 0 taken 1023544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1023544 times.
✗ Branch 3 not taken.
1023544 if(!p_getc(&(temp_meta.run_types[q]),f))
12894 {
12895 return qe_invalid;
12896 }
12897 1023544 }
12898
12899
2/4
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127943 times.
✗ Branch 3 not taken.
127943 if(!p_getc(&(temp_meta.flags),f))
12900 {
12901 return qe_invalid;
12902 }
12903
12904
2/4
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127943 times.
✗ Branch 3 not taken.
127943 if(!p_igetw(&(temp_meta.compiler_v1),f))
12905 {
12906 return qe_invalid;
12907 }
12908
12909
2/4
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127943 times.
✗ Branch 3 not taken.
127943 if(!p_igetw(&(temp_meta.compiler_v2),f))
12910 {
12911 return qe_invalid;
12912 }
12913
12914
2/4
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127943 times.
✗ Branch 3 not taken.
127943 if(!p_igetw(&(temp_meta.compiler_v3),f))
12915 {
12916 return qe_invalid;
12917 }
12918
12919
2/4
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127943 times.
✗ Branch 3 not taken.
127943 if(!p_igetw(&(temp_meta.compiler_v4),f))
12920 {
12921 return qe_invalid;
12922 }
12923
12924
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 120749 times.
127943 if(zmeta_version == 2)
12925 {
12926
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
12927 {
12928
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f))
12929 {
12930 return qe_invalid;
12931 }
12932 237402 }
12933
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.script_name.assign(b33);
12934
12935
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
12936 {
12937
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f))
12938 {
12939 return qe_invalid;
12940 }
12941 237402 }
12942
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.author.assign(b33);
12943 7194 }
12944
1/2
✓ Branch 0 taken 120749 times.
✗ Branch 1 not taken.
120749 else if(zmeta_version > 2)
12945 {
12946
2/4
✓ Branch 0 taken 120749 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120749 times.
✗ Branch 3 not taken.
120749 if(!p_getcstr(&temp_meta.script_name,f))
12947 return qe_invalid;
12948
2/4
✓ Branch 0 taken 120749 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120749 times.
✗ Branch 3 not taken.
120749 if(!p_getcstr(&temp_meta.author,f))
12949 return qe_invalid;
12950 120749 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
12951
2/2
✓ Branch 0 taken 1207490 times.
✓ Branch 1 taken 120749 times.
1328239 for(auto q = 0; q < num_meta_attrib; ++q)
12952 {
12953
2/4
✓ Branch 0 taken 1207490 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1207490 times.
✗ Branch 3 not taken.
1207490 if(!p_getcstr(&temp_meta.attributes[q],f))
12954 return qe_invalid;
12955
2/4
✓ Branch 0 taken 1207490 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1207490 times.
✗ Branch 3 not taken.
1207490 if(!p_getwstr(&temp_meta.attributes_help[q],f))
12956 return qe_invalid;
12957 1207490 }
12958
2/2
✓ Branch 0 taken 965992 times.
✓ Branch 1 taken 120749 times.
1086741 for(auto q = 0; q < 8; ++q)
12959 {
12960
2/4
✓ Branch 0 taken 965992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965992 times.
✗ Branch 3 not taken.
965992 if(!p_getcstr(&temp_meta.attribytes[q],f))
12961 return qe_invalid;
12962
2/4
✓ Branch 0 taken 965992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965992 times.
✗ Branch 3 not taken.
965992 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
12963 return qe_invalid;
12964 965992 }
12965
2/2
✓ Branch 0 taken 965992 times.
✓ Branch 1 taken 120749 times.
1086741 for(auto q = 0; q < 8; ++q)
12966 {
12967
2/4
✓ Branch 0 taken 965992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965992 times.
✗ Branch 3 not taken.
965992 if(!p_getcstr(&temp_meta.attrishorts[q],f))
12968 return qe_invalid;
12969
2/4
✓ Branch 0 taken 965992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965992 times.
✗ Branch 3 not taken.
965992 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
12970 return qe_invalid;
12971 965992 }
12972
2/2
✓ Branch 0 taken 1931984 times.
✓ Branch 1 taken 120749 times.
2052733 for(auto q = 0; q < 16; ++q)
12973 {
12974
2/4
✓ Branch 0 taken 1931984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1931984 times.
✗ Branch 3 not taken.
1931984 if(!p_getcstr(&temp_meta.usrflags[q],f))
12975 return qe_invalid;
12976
2/4
✓ Branch 0 taken 1931984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1931984 times.
✗ Branch 3 not taken.
1931984 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
12977 return qe_invalid;
12978 1931984 }
12979 120749 }
12980
2/2
✓ Branch 0 taken 120749 times.
✓ Branch 1 taken 7194 times.
127943 if(zmeta_version > 3)
12981 {
12982
2/2
✓ Branch 0 taken 965992 times.
✓ Branch 1 taken 120749 times.
1086741 for(auto q = 0; q < 8; ++q)
12983 {
12984
2/4
✓ Branch 0 taken 965992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965992 times.
✗ Branch 3 not taken.
965992 if(!p_getcstr(&temp_meta.initd[q],f))
12985 return qe_invalid;
12986
2/4
✓ Branch 0 taken 965992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965992 times.
✗ Branch 3 not taken.
965992 if(!p_getwstr(&temp_meta.initd_help[q],f))
12987 return qe_invalid;
12988 965992 }
12989
2/2
✓ Branch 0 taken 965992 times.
✓ Branch 1 taken 120749 times.
1086741 for(auto q = 0; q < 8; ++q)
12990 {
12991
2/4
✓ Branch 0 taken 965992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965992 times.
✗ Branch 3 not taken.
965992 if(!p_getc(&temp_meta.initd_type[q],f))
12992 return qe_invalid;
12993 965992 }
12994 120749 }
12995 else
12996 {
12997
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
12998 {
12999
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.initd[q] = temp_meta.run_idens[q];
13000 57552 }
13001 }
13002
13003
1/2
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
127943 (*script)->meta = temp_meta;
13004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127943 times.
127943 }
13005
13006
1/2
✓ Branch 0 taken 246754 times.
✗ Branch 1 not taken.
246754 temp_script.clear();
13007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21805856 times.
21805856 for(int32_t j=0; j<num_commands; j++)
13008 {
13009
2/4
✓ Branch 0 taken 21805856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21805856 times.
✗ Branch 3 not taken.
21805856 if(!p_igetw(&(temp_script.command),f))
13010 {
13011 return qe_invalid;
13012 }
13013
13014
2/2
✓ Branch 0 taken 246754 times.
✓ Branch 1 taken 21559102 times.
21805856 if(temp_script.command == 0xFFFF)
13015 {
13016
1/2
✓ Branch 0 taken 246754 times.
✗ Branch 1 not taken.
246754 (*script)->zasm[j].clear();
13017 246754 break;
13018 }
13019 else
13020 {
13021
2/4
✓ Branch 0 taken 21559102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21559102 times.
✗ Branch 3 not taken.
21559102 if(!p_igetl(&(temp_script.arg1),f))
13022 {
13023 return qe_invalid;
13024 }
13025
13026
2/4
✓ Branch 0 taken 21559102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21559102 times.
✗ Branch 3 not taken.
21559102 if(!p_igetl(&(temp_script.arg2),f))
13027 {
13028 return qe_invalid;
13029 }
13030
13031
2/2
✓ Branch 0 taken 886481 times.
✓ Branch 1 taken 20672621 times.
21559102 if(s_version >= 21)
13032 {
13033 886481 uint32_t sz = 0;
13034
2/4
✓ Branch 0 taken 886481 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 886481 times.
✗ Branch 3 not taken.
886481 if(!p_igetl(&sz,f))
13035 {
13036 return qe_invalid;
13037 }
13038
2/2
✓ Branch 0 taken 3164 times.
✓ Branch 1 taken 883317 times.
886481 if(sz) //string found
13039 {
13040
1/2
✓ Branch 0 taken 3164 times.
✗ Branch 1 not taken.
3164 temp_script.strptr = new std::string();
13041 char dummy;
13042
2/2
✓ Branch 0 taken 231986 times.
✓ Branch 1 taken 3164 times.
235150 for(size_t q = 0; q < sz; ++q)
13043 {
13044
2/4
✓ Branch 0 taken 231986 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 231986 times.
✗ Branch 3 not taken.
231986 if(!p_getc(&dummy,f))
13045 {
13046 return qe_invalid;
13047 }
13048
1/2
✓ Branch 0 taken 231986 times.
✗ Branch 1 not taken.
231986 temp_script.strptr->push_back(dummy);
13049 231986 }
13050 3164 }
13051
2/4
✓ Branch 0 taken 886481 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 886481 times.
✗ Branch 3 not taken.
886481 if(!p_igetl(&sz,f))
13052 {
13053 return qe_invalid;
13054 }
13055
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 886380 times.
886481 if(sz) //vector found
13056 {
13057
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 temp_script.vecptr = new std::vector<int32_t>();
13058 int32_t dummy;
13059
2/2
✓ Branch 0 taken 1487 times.
✓ Branch 1 taken 101 times.
1588 for(size_t q = 0; q < sz; ++q)
13060 {
13061
2/4
✓ Branch 0 taken 1487 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1487 times.
✗ Branch 3 not taken.
1487 if(!p_igetl(&dummy,f))
13062 {
13063 return qe_invalid;
13064 }
13065
1/2
✓ Branch 0 taken 1487 times.
✗ Branch 1 not taken.
1487 temp_script.vecptr->push_back(dummy);
13066 1487 }
13067 101 }
13068 886481 }
13069
13070
1/2
✓ Branch 0 taken 21559102 times.
✗ Branch 1 not taken.
21559102 temp_script.give((*script)->zasm[j]);
13071 }
13072
1/2
✓ Branch 0 taken 21559102 times.
✗ Branch 1 not taken.
21559102 temp_script.clear();
13073 21559102 }
13074
13075 246754 return 0;
13076 246754 }
13077
13078 extern SAMPLE customsfxdata[WAV_COUNT];
13079 extern uint8_t customsfxflag[WAV_COUNT>>3];
13080 extern int32_t sfxdat;
13081 extern DATAFILE *sfxdata;
13082 const char *old_sfx_string[Z35] =
13083 {
13084 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13085 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13086 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13087 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13088 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13089 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13090 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13091 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13092 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13093 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13094 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13095 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13096 };
13097 char *sfx_string[WAV_COUNT];
13098
13099 112 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13100 {
13101 //these are here to bypass compiler warnings about unused arguments
13102 112 Header=Header;
13103
13104 int32_t dummy;
13105 112 word s_version=0, s_cversion=0;
13106 //int32_t ret;
13107 112 SAMPLE temp_sample = {};
13108 112 temp_sample.loop_start=0;
13109 112 temp_sample.loop_end=0;
13110 112 temp_sample.param=0;
13111
13112 //section version info
13113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(!p_igetw(&s_version,f))
13114 {
13115 return qe_invalid;
13116 }
13117
13118 112 FFCore.quest_format[vSFX] = s_version;
13119
13120 //al_trace("SFX version %d\n", s_version);
13121
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetw(&s_cversion,f))
13122 {
13123 return qe_invalid;
13124 }
13125
13126 //section size
13127
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetl(&dummy,f))
13128 {
13129 return qe_invalid;
13130 }
13131
13132 /* HIGHLY UNORTHODOX UPDATING THING, by L
13133 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13134 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13135 * changing from 1 to 2.
13136 */
13137
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(s_version < 2)
13138 set_qr(qr_GOTOLESSNOTEQUAL,1);
13139
13140 /* End highly unorthodox updating thing */
13141
13142 112 int32_t wavcount = WAV_COUNT;
13143
13144
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(s_version < 6)
13145 wavcount = 128;
13146
13147 uint8_t tempflag[WAV_COUNT>>3];
13148
13149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(s_version < 4)
13150 {
13151 memset(tempflag, 0xFF, WAV_COUNT>>3);
13152 }
13153 else
13154 {
13155
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(s_version < 6)
13156 memset(tempflag, 0, WAV_COUNT>>3);
13157
13158
2/2
✓ Branch 0 taken 3584 times.
✓ Branch 1 taken 112 times.
3696 for(int32_t i=0; i<(wavcount>>3); i++)
13159 {
13160 3584 p_getc(&tempflag[i], f);
13161 3584 }
13162
13163 }
13164
13165
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(s_version>4)
13166 {
13167
2/2
✓ Branch 0 taken 28560 times.
✓ Branch 1 taken 112 times.
28672 for(int32_t i=1; i<WAV_COUNT; i++)
13168 {
13169 28560 sprintf(sfx_string[i],"s%03d",i);
13170
13171
2/2
✓ Branch 0 taken 21840 times.
✓ Branch 1 taken 6720 times.
28560 if((i<Z35))
13172 6720 strcpy(sfx_string[i], old_sfx_string[i-1]);
13173
13174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28560 times.
28560 if(i>=wavcount)
13175 continue;
13176
2/2
✓ Branch 0 taken 2999 times.
✓ Branch 1 taken 25561 times.
28560 if(get_bit(tempflag, i-1))
13177 {
13178 char tempname[36];
13179
13180
1/2
✓ Branch 0 taken 2999 times.
✗ Branch 1 not taken.
2999 if(!pfread(tempname, 36, f))
13181 {
13182 return qe_invalid;
13183 }
13184
13185 2999 sfx_string[i][0] = '\0';
13186 2999 strncat(sfx_string[i], tempname, 36 - 1);
13187 2999 }
13188 else
13189 {
13190 25561 sprintf(sfx_string[i],"s%03d",i);
13191
13192
2/2
✓ Branch 0 taken 20983 times.
✓ Branch 1 taken 4578 times.
25561 if(i<Z35)
13193 4578 strcpy(sfx_string[i], old_sfx_string[i-1]);
13194 25561 sfx_string[i][35] = 0; //Force NULL Termination
13195 }
13196 28560 }
13197 112 }
13198 else
13199 {
13200 for(int32_t i=1; i<WAV_COUNT; i++)
13201 {
13202 sprintf(sfx_string[i],"s%03d",i);
13203
13204 if(i<Z35)
13205 strcpy(sfx_string[i], old_sfx_string[i-1]);
13206 }
13207 }
13208
13209 //finally... section data
13210
2/2
✓ Branch 0 taken 28560 times.
✓ Branch 1 taken 112 times.
28672 for(int32_t i=1; i<wavcount; i++)
13211 {
13212
2/2
✓ Branch 0 taken 2999 times.
✓ Branch 1 taken 25561 times.
28560 if(get_bit(tempflag, i-1))
13213 {
13214
13215
1/2
✓ Branch 0 taken 2999 times.
✗ Branch 1 not taken.
2999 if(!p_igetl(&dummy,f))
13216 {
13217 return qe_invalid;
13218 }
13219
13220 2999 (temp_sample.bits) = dummy;
13221
13222
1/2
✓ Branch 0 taken 2999 times.
✗ Branch 1 not taken.
2999 if(!p_igetl(&dummy,f))
13223 {
13224 return qe_invalid;
13225 }
13226
13227 2999 (temp_sample.stereo) = dummy;
13228
13229
1/2
✓ Branch 0 taken 2999 times.
✗ Branch 1 not taken.
2999 if(!p_igetl(&dummy,f))
13230 {
13231 return qe_invalid;
13232 }
13233
13234 2999 (temp_sample.freq) = dummy;
13235
13236
1/2
✓ Branch 0 taken 2999 times.
✗ Branch 1 not taken.
2999 if(!p_igetl(&dummy,f))
13237 {
13238 return qe_invalid;
13239 }
13240
13241 2999 (temp_sample.priority) = dummy;
13242
13243
1/2
✓ Branch 0 taken 2999 times.
✗ Branch 1 not taken.
2999 if(!p_igetl(&(temp_sample.len),f))
13244 {
13245 return qe_invalid;
13246 }
13247
13248
1/2
✓ Branch 0 taken 2999 times.
✗ Branch 1 not taken.
2999 if(!p_igetl(&(temp_sample.loop_start),f))
13249 {
13250 return qe_invalid;
13251 }
13252
13253
1/2
✓ Branch 0 taken 2999 times.
✗ Branch 1 not taken.
2999 if(!p_igetl(&(temp_sample.loop_end),f))
13254 {
13255 return qe_invalid;
13256 }
13257
13258
1/2
✓ Branch 0 taken 2999 times.
✗ Branch 1 not taken.
2999 if(!p_igetl(&(temp_sample.param),f))
13259 {
13260 return qe_invalid;
13261 }
13262
13263 // al_trace("F%i: L%i\n",i,temp_sample.len);
13264 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13265 2999 auto len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13266
2/4
✓ Branch 0 taken 2999 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2999 times.
2999 if (len < 0 || len > 10000000)
13267 {
13268 return qe_invalid;
13269 }
13270 2999 temp_sample.data = calloc(len,1);
13271
13272
1/2
✓ Branch 0 taken 2999 times.
✗ Branch 1 not taken.
2999 if(s_version < 3)
13273 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13274
13275 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2999 times.
2999 if(s_version < 2)
13277 {
13278 if(!pfread(temp_sample.data, len,f))
13279 {
13280 return qe_invalid;
13281 }
13282 }
13283 else
13284 {
13285 //re-endianfy the data
13286 2999 int32_t wordstoread = len / sizeof(word);
13287
13288
2/2
✓ Branch 0 taken 87343682 times.
✓ Branch 1 taken 2999 times.
87346681 for(int32_t j=0; j<wordstoread; j++)
13289 {
13290 word temp;
13291
13292
1/2
✓ Branch 0 taken 87343682 times.
✗ Branch 1 not taken.
87343682 if(!p_igetw(&temp, f))
13293 {
13294 return qe_invalid;
13295 }
13296
13297 87343682 ((word *)temp_sample.data)[j] = temp;
13298 87343682 }
13299 }
13300 2999 }
13301
2/2
✓ Branch 0 taken 4578 times.
✓ Branch 1 taken 20983 times.
25561 else if(i < Z35)
13302 {
13303 4578 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13304 4578 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13305 4578 set_bit(tempflag, i-1, 1);
13306 4578 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13307 4578 temp_sample.data = calloc(len,1);
13308 4578 memcpy(temp_sample.data, datsamp->data, len);
13309 4578 }
13310 20983 else continue;
13311
13312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7577 times.
7577 if(customsfxdata[i].data!=NULL)
13313 {
13314 // delete [] customsfxdata[i].data;
13315 7577 free(customsfxdata[i].data);
13316 7577 }
13317
13318 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13319 7577 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13320 7577 customsfxdata[i].data = calloc(len2,1);
13321 7577 customsfxdata[i].bits = temp_sample.bits;
13322 7577 customsfxdata[i].stereo = temp_sample.stereo;
13323 7577 customsfxdata[i].freq = temp_sample.freq;
13324 7577 customsfxdata[i].priority = temp_sample.priority;
13325 7577 customsfxdata[i].len = temp_sample.len;
13326 7577 customsfxdata[i].loop_start = temp_sample.loop_start;
13327 7577 customsfxdata[i].loop_end = temp_sample.loop_end;
13328 7577 customsfxdata[i].param = temp_sample.param;
13329 7577 int32_t cpylen = len2;
13330
13331
1/2
✓ Branch 0 taken 7577 times.
✗ Branch 1 not taken.
7577 if(s_version<3)
13332 {
13333 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13334 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13335 }
13336
13337 7577 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13338
13339 7577 free(temp_sample.data);
13340 7577 }
13341
13342 112 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13343
13344 112 sfxdat=0;
13345 112 return 0;
13346 112 }
13347
13348 128 void setupsfx()
13349 {
13350
2/2
✓ Branch 0 taken 32640 times.
✓ Branch 1 taken 128 times.
32768 for(int32_t i=1; i<WAV_COUNT; i++)
13351 {
13352 32640 sprintf(sfx_string[i],"s%03d",i);
13353
13354
2/2
✓ Branch 0 taken 24960 times.
✓ Branch 1 taken 7680 times.
32640 if(i<Z35)
13355 {
13356 7680 strcpy(sfx_string[i], old_sfx_string[i-1]);
13357 7680 }
13358
13359 32640 memset(customsfxflag, 0, WAV_COUNT>>3);
13360
13361 32640 int32_t j=i;
13362
13363
2/2
✓ Branch 0 taken 7808 times.
✓ Branch 1 taken 24832 times.
32640 if(i>Z35)
13364 {
13365 24832 i=Z35;
13366 24832 }
13367
13368 32640 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13369
13370
2/2
✓ Branch 0 taken 29325 times.
✓ Branch 1 taken 3315 times.
32640 if(customsfxdata[j].data!=NULL)
13371 {
13372 // delete [] customsfxdata[j].data;
13373 3315 free(customsfxdata[j].data);
13374 3315 }
13375
13376 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13377 32640 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13378 32640 customsfxdata[j].bits = temp_sample->bits;
13379 32640 customsfxdata[j].stereo = temp_sample->stereo;
13380 32640 customsfxdata[j].freq = temp_sample->freq;
13381 32640 customsfxdata[j].priority = temp_sample->priority;
13382 32640 customsfxdata[j].len = temp_sample->len;
13383 32640 customsfxdata[j].loop_start = temp_sample->loop_start;
13384 32640 customsfxdata[j].loop_end = temp_sample->loop_end;
13385 32640 customsfxdata[j].param = temp_sample->param;
13386 32640 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13387 32640 i=j;
13388 32640 }
13389 128 }
13390
13391 extern char *guy_string[eMAXGUYS];
13392 extern const char *old_guy_string[OLDMAXGUYS];
13393
13394 128 int32_t readguys(PACKFILE *f, zquestheader *Header)
13395 {
13396
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_guys);
13397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (should_skip) return 0;
13398
13399 dword dummy;
13400 word guy_cversion;
13401 128 word guyversion=0;
13402
13403
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(Header->zelda_version >= 0x193)
13404 {
13405 //section version info
13406
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&guyversion,f))
13407 {
13408 return qe_invalid;
13409 }
13410
13411 124 FFCore.quest_format[vGuys] = guyversion;
13412
13413 //al_trace("Guys version %d\n", guyversion);
13414
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&guy_cversion,f))
13415 {
13416 return qe_invalid;
13417 }
13418 124 al_trace("Guy CVersion is: %d\n", guy_cversion);
13419 //section size
13420
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&dummy,f))
13421 {
13422 return qe_invalid;
13423 }
13424 124 }
13425
13426
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(guyversion > 3)
13427 {
13428
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 112 times.
57456 for(int32_t i=0; i<MAXGUYS; i++)
13429 {
13430 char tempname[64];
13431
13432 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13433 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13434
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 57344 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
57344 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13435 {
13436 memset(tempname, 0, sizeof(char)*64);
13437 sprintf(tempname, "e%03d", i);
13438 strcpy(guy_string[i], tempname);
13439
13440 continue;
13441 }
13442
13443
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!pfread(tempname, 64, f))
13444 {
13445 return qe_invalid;
13446 }
13447
13448 // Don't retain names of uneditable enemy entries!
13449 // for version upgrade to 2.5
13450
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 57344 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
57344 if(guyversion < 23 && i >= 177)
13451 {
13452 // some of the older builds have names such as 'zz123',
13453 // (this order gets messed up with some eXXX and some zzXXX)
13454 // so let's update to the newer naming convection. -Gleeok
13455 char tmpbuf[64];
13456 memset(tmpbuf, 0, sizeof(char)*64);
13457 sprintf(tmpbuf, "zz%03d", i);
13458
13459 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13460 {
13461 memset(tempname, 0, sizeof(char)*64);
13462 sprintf(tempname, "e%03d", i);
13463 }
13464 }
13465
13466
6/6
✓ Branch 0 taken 19824 times.
✓ Branch 1 taken 37520 times.
✓ Branch 2 taken 18816 times.
✓ Branch 3 taken 1008 times.
✓ Branch 4 taken 15792 times.
✓ Branch 5 taken 3024 times.
57344 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13467 {
13468 54320 guy_string[i][0] = '\0';
13469 54320 strncat(guy_string[i], tempname, 64 - 1);
13470 54320 }
13471 else
13472 {
13473 3024 strcpy(guy_string[i],old_guy_string[i]);
13474 }
13475 57344 }
13476 112 }
13477 else
13478 {
13479
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 16 times.
8208 for(int32_t i=0; i<eMAXGUYS; i++)
13480 {
13481 8192 sprintf(guy_string[i],"zz%03d",i);
13482 8192 }
13483
13484
2/2
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 16 times.
2848 for(int32_t i=0; i<OLDMAXGUYS; i++)
13485 {
13486 2832 strcpy(guy_string[i],old_guy_string[i]);
13487 2832 }
13488 }
13489
13490
13491 //finally... section data
13492 128 init_guys(guyversion); //using default data for now...
13493
13494 // Goriya guy fix
13495
3/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13496 {
13497
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
16 if(get_qr(qr_NEWENEMYTILES))
13498 {
13499 12 guysbuf[gGORIYA].tile=130;
13500 12 guysbuf[gGORIYA].e_tile=130;
13501 12 }
13502 16 }
13503
13504
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if(Header->zelda_version < 0x193)
13505 {
13506
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_bit(deprecated_rules,46))
13507 {
13508 guysbuf[eDODONGO].cset=14;
13509 guysbuf[eDODONGO].bosspal=spDIG;
13510 }
13511 4 }
13512 // Not sure when this first changed, but it's necessary for 2.10, at least
13513 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13514 //2.10 Fixes
13515
3/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13516 {
13517 16 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13518 16 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13519 16 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13520 16 guysbuf[eCENT1].misc3 = 1;
13521 16 guysbuf[eCENT2].misc3 = 1;
13522 16 }
13523
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13524 {
13525 128 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13526 128 }
13527
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(Header->zelda_version <= 0x210)
13528 {
13529 16 guysbuf[eGLEEOK1F].misc6 = 16;
13530 16 guysbuf[eGLEEOK2F].misc6 = 16;
13531 16 guysbuf[eGLEEOK3F].misc6 = 16;
13532 16 guysbuf[eGLEEOK4F].misc6 = 16;
13533
13534 16 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13535 16 guysbuf[eBATROBE].misc4 = 1;
13536 //guysbuf[eSUMMONER].misc4 = 1;
13537 16 guysbuf[eWWIZ].misc4 = 1;
13538 16 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13539 16 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13540 16 }
13541
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if(Header->zelda_version == 0x190)
13542 {
13543 4 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13544 4 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13545 4 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13546 4 }
13547
13548 // The versions here may not be correct
13549 // zelda_version>=0x211 handled at guyversion<24
13550
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(Header->zelda_version <= 0x190)
13551 {
13552 4 guysbuf[eCENT1].misc3 = 0;
13553 4 guysbuf[eCENT2].misc3 = 0;
13554 4 guysbuf[eMOLDORM].misc2 = 0;
13555 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13556 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13557 4 }
13558
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 12 times.
124 else if(Header->zelda_version <= 0x210)
13559 {
13560 12 guysbuf[eCENT1].misc3 = 1;
13561 12 guysbuf[eCENT2].misc3 = 1;
13562 12 guysbuf[eMOLDORM].misc2 = 0;
13563 12 }
13564
13565
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13566 {
13567 16 guysbuf[eKEESE1].misc16 = 120;
13568 16 guysbuf[eKEESE2].misc16 = 120;
13569 16 guysbuf[eKEESE3].misc16 = 120;
13570 16 guysbuf[eKEESETRIB].misc16 = 120;
13571 16 guysbuf[eKEESE1].misc17 = 16;
13572 16 guysbuf[eKEESE2].misc17 = 16;
13573 16 guysbuf[eKEESE3].misc17 = 16;
13574 16 guysbuf[eKEESETRIB].misc17 = 16;
13575
13576 16 guysbuf[ePEAHAT].misc16 = 80;
13577 16 guysbuf[ePEAHAT].misc17 = 16;
13578
13579 16 guysbuf[eGHINI2].misc16 = 120;
13580 16 guysbuf[eGHINI2].misc17 = 10;
13581
13582
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if (replay_version_check(20))
13583 {
13584 guysbuf[eGHINI2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13585 guysbuf[eMOLDORM].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13586 guysbuf[eKEESETRIB].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13587 guysbuf[eKEESE3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13588 guysbuf[eKEESE2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13589 guysbuf[eKEESE1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13590 guysbuf[eTEK1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13591 guysbuf[eTEK2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13592 guysbuf[ePEAHAT].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13593 guysbuf[eROCK].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13594 guysbuf[eTRAP].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13595 guysbuf[eWALLM].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13596 guysbuf[ePOLSV].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13597 guysbuf[eMANHAN].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13598 guysbuf[eGLEEOK1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13599 guysbuf[eGLEEOK2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13600 guysbuf[eGLEEOK3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13601 guysbuf[eGLEEOK4].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13602 guysbuf[eDIG1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13603 guysbuf[eDIG3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13604 guysbuf[eDIGPUP1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13605 guysbuf[eDIGPUP2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13606 guysbuf[eDIGPUP3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13607 guysbuf[eDIGPUP4].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13608 guysbuf[eRAQUAM].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13609 guysbuf[eITEMFAIRY].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13610 guysbuf[eFIRE].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13611 guysbuf[eMANHAN2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13612 guysbuf[eTRAP_H].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13613 guysbuf[eTRAP_V].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13614 guysbuf[eTRAP_LR].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13615 guysbuf[eTRAP_UD].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13616 guysbuf[ePATRA1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13617 guysbuf[ePATRA2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13618 guysbuf[ePATRABS].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13619 guysbuf[eBAT].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13620 guysbuf[eGLEEOK1F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13621 guysbuf[eGLEEOK2F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13622 guysbuf[eGLEEOK3F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13623 guysbuf[eGLEEOK4F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13624 guysbuf[eTRIGGER].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13625 guysbuf[ePATRAL2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13626 guysbuf[ePATRAL3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13627 guysbuf[eGOHMA1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13628 guysbuf[eGOHMA2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13629 guysbuf[eGOHMA3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13630 guysbuf[eGOHMA4].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13631 guysbuf[eMPOLSV].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13632 guysbuf[eWPOLSV].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13633 }
13634 16 }
13635
13636
13637
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 112 times.
128 if(guyversion<=2)
13638 {
13639 16 return readherosprites2(f, guyversion==2?0:-1, 0);
13640 }
13641
13642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(guyversion > 3)
13643 {
13644 guydata tempguy;
13645
13646
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 112 times.
57456 for(int32_t i=0; i<MAXGUYS; i++)
13647 {
13648
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 23) // May 2012 : 512 max enemies
13649 {
13650 if(i >= OLDBETAMAXGUYS)
13651 {
13652 memset(&guysbuf[i], 0, sizeof(guydata));
13653 continue;
13654 }
13655 }
13656
13657 57344 memset(&tempguy, 0, sizeof(guydata));
13658
13659
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.flags),f))
13660 {
13661 return qe_invalid;
13662 }
13663
13664
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.flags2),f))
13665 {
13666 return qe_invalid;
13667 }
13668
13669
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if ( guyversion >= 36 ) //expanded tiles
13670 {
13671
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.tile),f))
13672 {
13673 return qe_invalid;
13674 }
13675 17920 }
13676 else
13677 {
13678
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.tile),f))
13679 {
13680 return qe_invalid;
13681 }
13682 }
13683
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_getc(&(tempguy.width),f))
13684 {
13685 return qe_invalid;
13686 }
13687
13688
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_getc(&(tempguy.height),f))
13689 {
13690 return qe_invalid;
13691 }
13692
13693
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if ( guyversion >= 36 ) //expanded tiles
13694 {
13695
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.s_tile),f))
13696 {
13697 return qe_invalid;
13698 }
13699 17920 }
13700 else
13701 {
13702
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.s_tile),f))
13703 {
13704 return qe_invalid;
13705 }
13706 }
13707
13708
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_getc(&(tempguy.s_width),f))
13709 {
13710 return qe_invalid;
13711 }
13712
13713
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_getc(&(tempguy.s_height),f))
13714 {
13715 return qe_invalid;
13716 }
13717
13718
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if ( guyversion >= 36 ) //expanded tiles
13719 {
13720
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.e_tile),f))
13721 {
13722 return qe_invalid;
13723 }
13724 17920 }
13725 else
13726 {
13727
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.e_tile),f))
13728 {
13729 return qe_invalid;
13730 }
13731 }
13732
13733
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_getc(&(tempguy.e_width),f))
13734 {
13735 return qe_invalid;
13736 }
13737
13738
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_getc(&(tempguy.e_height),f))
13739 {
13740 return qe_invalid;
13741 }
13742
13743
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.hp),f))
13744 {
13745 return qe_invalid;
13746 }
13747
13748
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.family),f))
13749 {
13750 return qe_invalid;
13751 }
13752
13753
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 57344 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
57344 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13754 {
13755 if(get_qr(qr_NEWENEMYTILES))
13756 {
13757 tempguy.s_tile=tempguy.e_tile+120;
13758 tempguy.s_width=tempguy.e_width;
13759 tempguy.s_height=tempguy.e_height;
13760 }
13761 else tempguy.s_tile=860;
13762 }
13763
13764
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.cset),f))
13765 {
13766 return qe_invalid;
13767 }
13768
13769
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.anim),f))
13770 {
13771 return qe_invalid;
13772 }
13773
13774
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.e_anim),f))
13775 {
13776 return qe_invalid;
13777 }
13778
13779
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.frate),f))
13780 {
13781 return qe_invalid;
13782 }
13783
13784
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.e_frate),f))
13785 {
13786 return qe_invalid;
13787 }
13788
13789
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 13) // April 2009
13790 {
13791 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
13792 {
13793 tempguy.frate *= 2;
13794 tempguy.e_frate *= 2;
13795 }
13796 }
13797
13798
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 14) // May 1 2009
13799 {
13800 if(tempguy.anim==a2FRMSLOW)
13801 {
13802 tempguy.anim=a2FRM;
13803 tempguy.frate *= 2;
13804 }
13805
13806 if(tempguy.e_anim==a2FRMSLOW)
13807 {
13808 tempguy.e_anim=a2FRM;
13809 tempguy.e_frate *= 2;
13810 }
13811
13812 if(tempguy.anim==aFLIPSLOW)
13813 {
13814 tempguy.anim=aFLIP;
13815 tempguy.frate *= 2;
13816 }
13817
13818 if(tempguy.e_anim==aFLIPSLOW)
13819 {
13820 tempguy.e_anim=aFLIP;
13821 tempguy.e_frate *= 2;
13822 }
13823
13824 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
13825
13826 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
13827
13828 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
13829 {
13830 tempguy.anim=a4FRM4DIR;
13831 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
13832 }
13833
13834 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
13835 {
13836 tempguy.e_anim=a4FRM4DIR;
13837 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
13838 }
13839 }
13840
13841
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.dp),f))
13842 {
13843 return qe_invalid;
13844 }
13845
13846 //correction for guy fire
13847
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 6)
13848 {
13849 if(i == gFIRE)
13850 tempguy.dp = 2;
13851 }
13852
13853
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.wdp),f))
13854 {
13855 return qe_invalid;
13856 }
13857
13858
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.weapon),f))
13859 {
13860 return qe_invalid;
13861 }
13862
13863 //correction for bosses using triple, "rising" fireballs
13864
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 5)
13865 {
13866 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
13867 i == eGOHMA3 || i == eGOHMA4)
13868 {
13869 if(tempguy.weapon == ewFireball)
13870 tempguy.weapon = ewFireball2;
13871 }
13872 }
13873
13874
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.rate),f))
13875 {
13876 return qe_invalid;
13877 }
13878
13879
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.hrate),f))
13880 {
13881 return qe_invalid;
13882 }
13883
13884
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.step),f))
13885 {
13886 return qe_invalid;
13887 }
13888
13889 // HIGHLY UNORTHODOX UPDATING THING, part 2
13890
3/4
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 55808 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
57344 if(fixpolsvoice && tempguy.family==eePOLSV)
13891 {
13892 tempguy.step /= 2;
13893 }
13894
13895
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.homing),f))
13896 {
13897 return qe_invalid;
13898 }
13899
13900
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.grumble),f))
13901 {
13902 return qe_invalid;
13903 }
13904
13905
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.item_set),f))
13906 {
13907 return qe_invalid;
13908 }
13909
13910
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
13911 {
13912
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.misc1),f))
13913 {
13914 return qe_invalid;
13915 }
13916
13917
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.misc2),f))
13918 {
13919 return qe_invalid;
13920 }
13921
13922
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.misc3),f))
13923 {
13924 return qe_invalid;
13925 }
13926
13927
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.misc4),f))
13928 {
13929 return qe_invalid;
13930 }
13931
13932
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.misc5),f))
13933 {
13934 return qe_invalid;
13935 }
13936
13937
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.misc6),f))
13938 {
13939 return qe_invalid;
13940 }
13941
13942
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.misc7),f))
13943 {
13944 return qe_invalid;
13945 }
13946
13947
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.misc8),f))
13948 {
13949 return qe_invalid;
13950 }
13951
13952
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.misc9),f))
13953 {
13954 return qe_invalid;
13955 }
13956
13957
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.misc10),f))
13958 {
13959 return qe_invalid;
13960 }
13961 57344 }
13962 else
13963 {
13964 int16_t tempMisc;
13965
13966 if(!p_igetw(&tempMisc,f))
13967 {
13968 return qe_invalid;
13969 }
13970
13971 tempguy.misc1=tempMisc;
13972
13973 if(!p_igetw(&tempMisc,f))
13974 {
13975 return qe_invalid;
13976 }
13977
13978 tempguy.misc2=tempMisc;
13979
13980 if(!p_igetw(&tempMisc,f))
13981 {
13982 return qe_invalid;
13983 }
13984
13985 tempguy.misc3=tempMisc;
13986
13987 if(!p_igetw(&tempMisc,f))
13988 {
13989 return qe_invalid;
13990 }
13991
13992 tempguy.misc4=tempMisc;
13993
13994 if(!p_igetw(&tempMisc,f))
13995 {
13996 return qe_invalid;
13997 }
13998
13999 tempguy.misc5=tempMisc;
14000
14001 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14002 {
14003 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
14004 tempguy.misc5 = 74;
14005 }
14006
14007 if(!p_igetw(&tempMisc,f))
14008 {
14009 return qe_invalid;
14010 }
14011
14012 tempguy.misc6=tempMisc;
14013
14014 if(!p_igetw(&tempMisc,f))
14015 {
14016 return qe_invalid;
14017 }
14018
14019 tempguy.misc7=tempMisc;
14020
14021 if(!p_igetw(&tempMisc,f))
14022 {
14023 return qe_invalid;
14024 }
14025
14026 tempguy.misc8=tempMisc;
14027
14028 if(!p_igetw(&tempMisc,f))
14029 {
14030 return qe_invalid;
14031 }
14032
14033 tempguy.misc9=tempMisc;
14034
14035 if(!p_igetw(&tempMisc,f))
14036 {
14037 return qe_invalid;
14038 }
14039
14040 tempguy.misc10=tempMisc;
14041 }
14042
14043
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.bgsfx),f))
14044 {
14045 return qe_invalid;
14046 }
14047
14048
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.bosspal),f))
14049 {
14050 return qe_invalid;
14051 }
14052
14053
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.extend),f))
14054 {
14055 return qe_invalid;
14056 }
14057
14058 //! Enemy Defences
14059
14060 //If a 2.50 quest, use only the 2.5 defences.
14061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57344 times.
57344 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14062 {
14063
2/2
✓ Branch 0 taken 1089536 times.
✓ Branch 1 taken 57344 times.
1146880 for(int32_t j=0; j<edefLAST; j++)
14064 {
14065
1/2
✓ Branch 0 taken 1089536 times.
✗ Branch 1 not taken.
1089536 if(!p_getc(&(tempguy.defense[j]),f))
14066 {
14067 return qe_invalid;
14068 }
14069 1089536 }
14070 //then copy the generic script defence to all the new script defences
14071
14072 57344 }
14073
14074
14075
14076
14077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57344 times.
57344 if(guyversion >= 18)
14078 {
14079
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_getc(&(tempguy.hitsfx),f))
14080 {
14081 return qe_invalid;
14082 }
14083
14084
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_getc(&(tempguy.deadsfx),f))
14085 {
14086 return qe_invalid;
14087 }
14088 57344 }
14089
14090
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion >= 22)
14091 {
14092
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.misc11),f))
14093 {
14094 return qe_invalid;
14095 }
14096
14097
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.misc12),f))
14098 {
14099 return qe_invalid;
14100 }
14101 57344 }
14102 else if(guyversion >= 19)
14103 {
14104 int16_t tempMisc;
14105
14106 if(!p_igetw(&tempMisc,f))
14107 {
14108 return qe_invalid;
14109 }
14110
14111 tempguy.misc11=tempMisc;
14112
14113 if(!p_igetw(&tempMisc,f))
14114 {
14115 return qe_invalid;
14116 }
14117
14118 tempguy.misc12=tempMisc;
14119 }
14120
14121 //If a 2.54 or later quest, use all of the defences.
14122
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
57344 if(guyversion > 24) // Add new guyversion conditional statement
14123 {
14124
2/2
✓ Branch 0 taken 394240 times.
✓ Branch 1 taken 17920 times.
412160 for(int32_t j=edefLAST; j<edefLAST255; j++)
14125 {
14126
1/2
✓ Branch 0 taken 394240 times.
✗ Branch 1 not taken.
394240 if(!p_getc(&(tempguy.defense[j]),f))
14127 {
14128 return qe_invalid;
14129 }
14130 394240 }
14131 17920 }
14132
14133
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14134 {
14135
2/2
✓ Branch 0 taken 394240 times.
✓ Branch 1 taken 39424 times.
433664 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14136 {
14137 394240 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14138 394240 }
14139 39424 }
14140
14141 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14142
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
57344 if(guyversion > 25)
14143 {
14144
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.txsz),f))
14145 {
14146 return qe_invalid;
14147 }
14148
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.tysz),f))
14149 {
14150 return qe_invalid;
14151 }
14152
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.hxsz),f))
14153 {
14154 return qe_invalid;
14155 }
14156
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.hysz),f))
14157 {
14158 return qe_invalid;
14159 }
14160
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.hzsz),f))
14161 {
14162 return qe_invalid;
14163 }
14164 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14165
14166 */
14167 17920 }
14168 //More Enemy Editor vars for 2.60
14169
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
57344 if(guyversion > 26)
14170 {
14171
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.hxofs),f))
14172 {
14173 return qe_invalid;
14174 }
14175
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.hyofs),f))
14176 {
14177 return qe_invalid;
14178 }
14179
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.xofs),f))
14180 {
14181 return qe_invalid;
14182 }
14183
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.yofs),f))
14184 {
14185 return qe_invalid;
14186 }
14187
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.zofs),f))
14188 {
14189 return qe_invalid;
14190 }
14191 17920 }
14192
14193
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14194 {
14195 39424 tempguy.wpnsprite = 0;
14196 39424 }
14197
14198
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
57344 if(guyversion > 27)
14199 {
14200
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.wpnsprite),f))
14201 {
14202 return qe_invalid;
14203 }
14204 17920 }
14205
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14206 {
14207 39424 tempguy.SIZEflags = 0;
14208 39424 }
14209
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
57344 if(guyversion > 28)
14210 {
14211
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.SIZEflags),f))
14212 {
14213 return qe_invalid;
14214 }
14215
14216 17920 }
14217
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14218 {
14219 39424 tempguy.frozentile = 0;
14220 39424 tempguy.frozencset = 0;
14221 39424 tempguy.frozenclock = 0;
14222
2/2
✓ Branch 0 taken 394240 times.
✓ Branch 1 taken 39424 times.
433664 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14223 39424 }
14224
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
57344 if(guyversion >= 30)
14225 {
14226
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.frozentile),f))
14227 {
14228 return qe_invalid;
14229 }
14230
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.frozencset),f))
14231 {
14232 return qe_invalid;
14233 }
14234
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.frozenclock),f))
14235 {
14236 return qe_invalid;
14237 }
14238
2/2
✓ Branch 0 taken 179200 times.
✓ Branch 1 taken 17920 times.
197120 for ( int32_t q = 0; q < 10; q++ ) {
14239
1/2
✓ Branch 0 taken 179200 times.
✗ Branch 1 not taken.
179200 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14240 {
14241 return qe_invalid;
14242 }
14243 179200 }
14244
14245 17920 }
14246
14247
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
57344 if(guyversion >= 34)
14248 {
14249
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetw(&(tempguy.firesfx),f))
14250 {
14251 return qe_invalid;
14252 }
14253
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc16),f))
14254 {
14255 return qe_invalid;
14256 }
14257
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc17),f))
14258 {
14259 return qe_invalid;
14260 }
14261
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc18),f))
14262 {
14263 return qe_invalid;
14264 }
14265
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc19),f))
14266 {
14267 return qe_invalid;
14268 }
14269
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc20),f))
14270 {
14271 return qe_invalid;
14272 }
14273
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc21),f))
14274 {
14275 return qe_invalid;
14276 }
14277
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc22),f))
14278 {
14279 return qe_invalid;
14280 }
14281
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc23),f))
14282 {
14283 return qe_invalid;
14284 }
14285
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc24),f))
14286 {
14287 return qe_invalid;
14288 }
14289
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc25),f))
14290 {
14291 return qe_invalid;
14292 }
14293
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc26),f))
14294 {
14295 return qe_invalid;
14296 }
14297
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc27),f))
14298 {
14299 return qe_invalid;
14300 }
14301
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc28),f))
14302 {
14303 return qe_invalid;
14304 }
14305
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc29),f))
14306 {
14307 return qe_invalid;
14308 }
14309
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc30),f))
14310 {
14311 return qe_invalid;
14312 }
14313
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc31),f))
14314 {
14315 return qe_invalid;
14316 }
14317
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc32),f))
14318 {
14319 return qe_invalid;
14320 }
14321
14322
2/2
✓ Branch 0 taken 573440 times.
✓ Branch 1 taken 17920 times.
591360 for ( int32_t q = 0; q < 32; q++ ) {
14323
1/2
✓ Branch 0 taken 573440 times.
✗ Branch 1 not taken.
573440 if(!p_igetl(&(tempguy.movement[q]),f))
14324 {
14325 return qe_invalid;
14326 }
14327 573440 }
14328
2/2
✓ Branch 0 taken 573440 times.
✓ Branch 1 taken 17920 times.
591360 for ( int32_t q = 0; q < 32; q++ ) {
14329
1/2
✓ Branch 0 taken 573440 times.
✗ Branch 1 not taken.
573440 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14330 {
14331 return qe_invalid;
14332 }
14333 573440 }
14334
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetw(&(tempguy.script),f))
14335 {
14336 return qe_invalid;
14337 }
14338 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14339
2/2
✓ Branch 0 taken 143360 times.
✓ Branch 1 taken 17920 times.
161280 for ( int32_t q = 0; q < 8; q++ )
14340 {
14341
1/2
✓ Branch 0 taken 143360 times.
✗ Branch 1 not taken.
143360 if(!p_igetl(&(tempguy.initD[q]),f))
14342 {
14343 return qe_invalid;
14344 }
14345 143360 }
14346
2/2
✓ Branch 0 taken 35840 times.
✓ Branch 1 taken 17920 times.
53760 for ( int32_t q = 0; q < 2; q++ )
14347 {
14348
1/2
✓ Branch 0 taken 35840 times.
✗ Branch 1 not taken.
35840 if(!p_igetl(&(tempguy.initA[q]),f))
14349 {
14350 return qe_invalid;
14351 }
14352 35840 }
14353
14354 17920 }
14355
14356
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
57344 if(guyversion >= 37)
14357 {
14358
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.editorflags),f))
14359 {
14360 return qe_invalid;
14361 }
14362 17920 }
14363
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14364
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
57344 if(guyversion >= 38)
14365 {
14366
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc13),f))
14367 {
14368 return qe_invalid;
14369 }
14370
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc14),f))
14371 {
14372 return qe_invalid;
14373 }
14374
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc15),f))
14375 {
14376 return qe_invalid;
14377 }
14378
14379 17920 }
14380
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if ( guyversion < 38 )
14381 {
14382 39424 tempguy.misc13 = 0;
14383 39424 tempguy.misc14 = 0;
14384 39424 tempguy.misc15 = 0;
14385 39424 }
14386
14387
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
57344 if ( guyversion >= 39 )
14388 {
14389
2/2
✓ Branch 0 taken 143360 times.
✓ Branch 1 taken 17920 times.
161280 for ( int32_t q = 0; q < 8; q++ )
14390 {
14391
2/2
✓ Branch 0 taken 9318400 times.
✓ Branch 1 taken 143360 times.
9461760 for ( int32_t w = 0; w < 65; w++ )
14392 {
14393
1/2
✓ Branch 0 taken 9318400 times.
✗ Branch 1 not taken.
9318400 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14394 {
14395 return qe_invalid;
14396 }
14397 9318400 }
14398
2/2
✓ Branch 0 taken 9318400 times.
✓ Branch 1 taken 143360 times.
9461760 for ( int32_t w = 0; w < 65; w++ )
14399 {
14400
1/2
✓ Branch 0 taken 9318400 times.
✗ Branch 1 not taken.
9318400 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f))
14401 {
14402 return qe_invalid;
14403 }
14404 9318400 }
14405 143360 }
14406
14407
14408 17920 }
14409
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if ( guyversion < 39 ) //apply old InitD strings to both
14410 {
14411
2/2
✓ Branch 0 taken 315392 times.
✓ Branch 1 taken 39424 times.
354816 for ( int32_t q = 0; q < 8; q++ )
14412 {
14413 315392 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14414 315392 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14415 315392 }
14416 39424 }
14417
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
57344 if ( guyversion >= 40 )
14418 {
14419
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetw(&(tempguy.weaponscript),f))
14420 {
14421 return qe_invalid;
14422 }
14423 17920 }
14424
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if ( guyversion < 40 )
14425 {
14426 39424 tempguy.weaponscript = 0;
14427 39424 }
14428 //eweapon script InitD
14429
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
57344 if ( guyversion >= 41 )
14430 {
14431
2/2
✓ Branch 0 taken 143360 times.
✓ Branch 1 taken 17920 times.
161280 for ( int32_t q = 0; q < 8; q++ )
14432 {
14433
1/2
✓ Branch 0 taken 143360 times.
✗ Branch 1 not taken.
143360 if(!p_igetl(&(tempguy.weap_initiald[q]),f))
14434 {
14435 return qe_invalid;
14436 }
14437 143360 }
14438
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if ( guy_cversion < 4 )
14439 {
14440 if ( tempguy.family == eeKEESE )
14441 {
14442
14443 if ( !tempguy.misc1 )
14444 {
14445 tempguy.misc16 = 120;
14446 tempguy.misc17 = 16;
14447
14448 }
14449 }
14450 if ( tempguy.family == eePEAHAT )
14451 {
14452 tempguy.misc16 = 80;
14453 tempguy.misc17 = 16;
14454 }
14455
14456 if ( tempguy.family == eeGHINI )
14457 {
14458 tempguy.misc16 = 120;
14459 tempguy.misc17 = 10;
14460 }
14461
14462 }
14463 17920 }
14464
14465
14466
14467 //default weapon sprites (quest version < 2.54)
14468 //port over old defaults -Z
14469
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if(guyversion < 32)
14470 {
14471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39424 times.
39424 if ( tempguy.wpnsprite <= 0 )
14472 {
14473
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32842 times.
✓ Branch 4 taken 302 times.
✓ Branch 5 taken 314 times.
✓ Branch 6 taken 931 times.
✓ Branch 7 taken 493 times.
✓ Branch 8 taken 912 times.
✓ Branch 9 taken 80 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 137 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 363 times.
✓ Branch 14 taken 759 times.
✓ Branch 15 taken 106 times.
✓ Branch 16 taken 80 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 765 times.
39424 switch(tempguy.weapon)
14474 {
14475 case wNone:
14476 32842 tempguy.wpnsprite = 0; break;
14477
14478 case wSword:
14479 case wBeam:
14480 case wBrang:
14481 case wBomb:
14482 case wSBomb:
14483 case wLitBomb:
14484 case wLitSBomb:
14485 case wArrow:
14486 case wFire:
14487 case wWhistle:
14488 case wBait:
14489 case wWand:
14490 case wMagic:
14491 case wCatching:
14492 case wWind:
14493 case wRefMagic:
14494 case wRefFireball:
14495 case wRefRock:
14496 case wHammer:
14497 case wHookshot:
14498 case wHSHandle:
14499 case wHSChain:
14500 case wSSparkle:
14501 case wFSparkle:
14502 case wSmack:
14503 case wPhantom:
14504 case wCByrna:
14505 case wRefBeam:
14506 case wStomp:
14507 case lwMax:
14508 case wScript1:
14509 case wScript2:
14510 case wScript3:
14511 case wScript4:
14512 case wScript5:
14513 case wScript6:
14514 case wScript7:
14515 case wScript8:
14516 case wScript9:
14517 case wScript10:
14518 case wIce:
14519 //Cannot use any of these weapons yet.
14520 tempguy.wpnsprite = -1;
14521 break;
14522
14523 case wEnemyWeapons:
14524 1303 case ewFireball: tempguy.wpnsprite = 17; break;
14525
14526 302 case ewArrow: tempguy.wpnsprite = 19; break;
14527 314 case ewBrang: tempguy.wpnsprite = 4; break;
14528 931 case ewSword: tempguy.wpnsprite = 20; break;
14529 493 case ewRock: tempguy.wpnsprite = 18; break;
14530 912 case ewMagic: tempguy.wpnsprite = 21; break;
14531 80 case ewBomb: tempguy.wpnsprite = 78; break;
14532 18 case ewSBomb: tempguy.wpnsprite = 79; break;
14533 137 case ewLitBomb: tempguy.wpnsprite = 76; break;
14534 19 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14535 363 case ewFireTrail: tempguy.wpnsprite = 80; break;
14536 759 case ewFlame: tempguy.wpnsprite = 35; break;
14537 106 case ewWind: tempguy.wpnsprite = 36; break;
14538 80 case ewFlame2: tempguy.wpnsprite = 81; break;
14539 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14540 case ewIce: tempguy.wpnsprite = 83; break;
14541 765 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14542
14543
14544 default: break; //No assign.
14545 }
14546 39424 }
14547 39424 }
14548
14549 //default weapon fire sound (quest version < 2.54)
14550 //port over old defaults and zero new data. -Z
14551
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if(guyversion < 34)
14552 {
14553
2/2
✓ Branch 0 taken 1261568 times.
✓ Branch 1 taken 39424 times.
1300992 for ( int32_t q = 0; q < 32; q++ )
14554 {
14555 1261568 tempguy.movement[q] = 0;
14556 1261568 tempguy.new_weapon[q] = 0;
14557
14558 1261568 }
14559
14560 //NPC Script attributes.
14561 39424 tempguy.script = 0; //No scripted enemies existed. -Z
14562
2/2
✓ Branch 0 taken 315392 times.
✓ Branch 1 taken 39424 times.
354816 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14563
2/2
✓ Branch 0 taken 78848 times.
✓ Branch 1 taken 39424 times.
118272 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14564
14565 39424 tempguy.misc16 = 0;
14566 39424 tempguy.misc17 = 0;
14567 39424 tempguy.misc18 = 0;
14568 39424 tempguy.misc19 = 0;
14569 39424 tempguy.misc20 = 0;
14570 39424 tempguy.misc21 = 0;
14571 39424 tempguy.misc22 = 0;
14572 39424 tempguy.misc23 = 0;
14573 39424 tempguy.misc24 = 0;
14574 39424 tempguy.misc25 = 0;
14575 39424 tempguy.misc26 = 0;
14576 39424 tempguy.misc27 = 0;
14577 39424 tempguy.misc28 = 0;
14578 39424 tempguy.misc29 = 0;
14579 39424 tempguy.misc30 = 0;
14580 39424 tempguy.misc31 = 0;
14581 39424 tempguy.misc32 = 0;
14582
14583 //old default sounds
14584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39424 times.
39424 if ( tempguy.firesfx <= 0 )
14585 {
14586
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32842 times.
✓ Branch 4 taken 302 times.
✓ Branch 5 taken 314 times.
✓ Branch 6 taken 931 times.
✓ Branch 7 taken 493 times.
✓ Branch 8 taken 912 times.
✓ Branch 9 taken 80 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 137 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 363 times.
✓ Branch 14 taken 759 times.
✓ Branch 15 taken 106 times.
✓ Branch 16 taken 80 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 765 times.
39424 switch(tempguy.weapon)
14587 {
14588 case wNone:
14589 32842 tempguy.firesfx = 0; break;
14590
14591 case wSword:
14592 case wBeam:
14593 case wBrang:
14594 case wBomb:
14595 case wSBomb:
14596 case wLitBomb:
14597 case wLitSBomb:
14598 case wArrow:
14599 case wFire:
14600 case wWhistle:
14601 case wBait:
14602 case wWand:
14603 case wMagic:
14604 case wCatching:
14605 case wWind:
14606 case wRefMagic:
14607 case wRefFireball:
14608 case wRefRock:
14609 case wHammer:
14610 case wHookshot:
14611 case wHSHandle:
14612 case wHSChain:
14613 case wSSparkle:
14614 case wFSparkle:
14615 case wSmack:
14616 case wPhantom:
14617 case wCByrna:
14618 case wRefBeam:
14619 case wStomp:
14620 case lwMax:
14621 case wScript1:
14622 case wScript2:
14623 case wScript3:
14624 case wScript4:
14625 case wScript5:
14626 case wScript6:
14627 case wScript7:
14628 case wScript8:
14629 case wScript9:
14630 case wScript10:
14631 case wIce:
14632 //Cannot use any of these weapons yet.
14633 tempguy.firesfx = -1;
14634 break;
14635
14636 case wEnemyWeapons:
14637 1303 case ewFireball: tempguy.firesfx = 40; break;
14638
14639 302 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14640 314 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14641 931 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14642 493 case ewRock: tempguy.firesfx = 51; break;
14643 912 case ewMagic: tempguy.firesfx = 32; break;
14644 80 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14645 18 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14646 137 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14647 19 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14648 363 case ewFireTrail: tempguy.firesfx = 13; break;
14649 759 case ewFlame: tempguy.firesfx = 13; break;
14650 106 case ewWind: tempguy.firesfx = 32; break;
14651 80 case ewFlame2: tempguy.firesfx = 13; break;
14652 case ewFlame2Trail: tempguy.firesfx = 13; break;
14653 case ewIce: tempguy.firesfx = 44; break;
14654 765 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14655
14656 //what about special attacks (e.g. summoning == 56)
14657 default: break; //No assign.
14658 }
14659 39424 }
14660 39424 }
14661
14662 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14663
4/6
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
✓ Branch 2 taken 17920 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 17920 times.
57344 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14664 {
14665
2/2
✓ Branch 0 taken 3549 times.
✓ Branch 1 taken 35875 times.
39424 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14666 39424 }
14667 //Keese and bat halt rates.
14668
3/4
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39424 times.
57344 if ( guyversion < 42 && guy_cversion < 4 )
14669 {
14670
14671
2/2
✓ Branch 0 taken 38895 times.
✓ Branch 1 taken 529 times.
39424 if ( tempguy.family == eeKEESE )
14672 {
14673
14674
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 326 times.
529 if ( !tempguy.misc1 )
14675 {
14676 326 tempguy.misc16 = 120;
14677 326 tempguy.misc17 = 16;
14678
14679 326 }
14680 529 }
14681
2/2
✓ Branch 0 taken 39257 times.
✓ Branch 1 taken 167 times.
39424 if ( tempguy.family == eePEAHAT )
14682 {
14683 167 tempguy.misc16 = 80;
14684 167 tempguy.misc17 = 16;
14685 167 }
14686
2/2
✓ Branch 0 taken 39347 times.
✓ Branch 1 taken 77 times.
39424 if ( tempguy.family == eeGHINI )
14687 {
14688 77 tempguy.misc16 = 120;
14689 77 tempguy.misc17 = 10;
14690 77 }
14691
14692
14693 39424 }
14694
14695
14696 //miscellaneous other corrections
14697 //fix the mirror wizzrobe -DD
14698
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 7)
14699 {
14700 if(i == eMWIZ)
14701 {
14702 tempguy.misc2 = 0;
14703 tempguy.misc4 = 1;
14704 }
14705 }
14706
14707
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 8)
14708 {
14709 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14710 {
14711 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14712 tempguy.misc5 = 4; //neck length in segments
14713 tempguy.misc6 = 8; //neck offset from first body tile
14714 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
14715 tempguy.misc8 = 168; //head offset from first body tile
14716 tempguy.misc9 = 228; //flying head offset from first body tile
14717
14718 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14719 {
14720 tempguy.misc6 += 10; //neck offset from first body tile
14721 tempguy.misc8 -= 12; //head offset from first body tile
14722 }
14723 }
14724 }
14725
14726
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14727 {
14728 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
14729 tempguy.bosspal = spDIG;
14730 }
14731
14732
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 11) // December 2007 - Spinning Tile fix
14733 {
14734 if(tempguy.family==eeSPINTILE)
14735 {
14736 tempguy.flags |= guy_superman;
14737 tempguy.item_set = 0; // Don't drop items
14738 tempguy.step = 300;
14739 }
14740 }
14741
14742
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14743 {
14744 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14745 {
14746 if(tempguy.family==eeROPE)
14747 {
14748 tempguy.flags2 &= ~guy_flashing;
14749 }
14750 }
14751
14752 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14753 {
14754 if(tempguy.family==eeBUBBLE)
14755 {
14756 tempguy.flags2 &= ~guy_flashing;
14757 }
14758 }
14759
14760 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
14761 {
14762 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14763 {
14764 tempguy.flags2 |= guy_blinking;
14765 }
14766
14767 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14768 {
14769 tempguy.flags2 |= guy_transparent;
14770 }
14771 }
14772 }
14773
14774
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14775 {
14776 if(i==gFIRE)
14777 {
14778 tempguy.e_anim = aFLIP;
14779 tempguy.e_frate = 24;
14780 }
14781
14782 if(i==gFAIRY)
14783 {
14784 tempguy.e_anim = a2FRM;
14785 tempguy.e_frate = 16;
14786 }
14787 }
14788
14789
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14790 {
14791 if(i==0) Z_message("Updating guys to version 16...\n");
14792
14793 update_guy_1(&tempguy);
14794
14795 if(i==eMPOLSV)
14796 {
14797 tempguy.defense[edefARROW] = edCHINK;
14798 tempguy.defense[edefMAGIC] = ed1HKO;
14799 tempguy.defense[edefREFMAGIC] = ed1HKO;
14800 }
14801 }
14802
14803
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 17) // December 2009
14804 {
14805 if(tempguy.family==eePROJECTILE)
14806 {
14807 tempguy.misc1 = 0;
14808 }
14809 }
14810
14811
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 18) // January 2010
14812 {
14813 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
14814 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
14815
14816 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
14817 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
14818
14819 if(tempguy.family == eeAQUA)
14820 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
14821 else if(tempguy.family == eeMANHAN)
14822 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
14823 else if(tempguy.family==eePATRA)
14824 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14825 else if(tempguy.family==eeGHOMA)
14826 {
14827 for(int32_t j=0; j<edefLAST; j++)
14828 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
14829
14830 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
14831
14832 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
14833
14834 tempguy.misc1--;
14835 }
14836 else if(tempguy.family == eeGLEEOK)
14837 {
14838 for(int32_t j=0; j<edefLAST; j++)
14839 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14840
14841 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
14842 }
14843 else if(tempguy.family == eeARMOS)
14844 {
14845 tempguy.family=eeWALK;
14846 tempguy.hrate = 0;
14847 tempguy.misc10 = tempguy.misc1;
14848 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
14849 tempguy.misc9 = e9tARMOS;
14850 }
14851 else if(tempguy.family == eeGHINI && !tempguy.misc1)
14852 {
14853 tempguy.family=eeWALK;
14854 tempguy.hrate = 0;
14855 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
14856 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
14857 }
14858
14859 // Spawn animation flags
14860 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
14861 tempguy.flags |= guy_fadeflicker;
14862 else
14863 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
14864 }
14865
14866
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 20) // April 2010
14867 {
14868 if(tempguy.family == eeTRAP)
14869 {
14870 tempguy.misc2 = tempguy.misc10;
14871
14872 if(tempguy.misc10>=1)
14873 {
14874 tempguy.misc1++;
14875 }
14876
14877 tempguy.misc10 = 0;
14878 }
14879
14880 // Bomb Blast fix
14881 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
14882 tempguy.weapon = ewLitBomb;
14883 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
14884 tempguy.weapon = ewLitSBomb;
14885 }
14886
14887
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 21) // September 2011
14888 {
14889 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
14890 {
14891 if(tempguy.family == eeKEESETRIB)
14892 {
14893 tempguy.family = eeKEESE;
14894 tempguy.misc2 = e2tKEESETRIB;
14895 tempguy.misc1 = 0;
14896 }
14897
14898 tempguy.rate = 2;
14899 tempguy.hrate = 8;
14900 tempguy.homing = 0;
14901 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
14902 }
14903 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
14904 {
14905 if(tempguy.family == eePEAHAT)
14906 {
14907 tempguy.rate = 4;
14908 tempguy.step = 62;
14909 }
14910 else
14911 tempguy.step = 25;
14912
14913 tempguy.hrate = 8;
14914 tempguy.homing = 0;
14915 }
14916 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
14917 {
14918 if(tempguy.family == eeMANHAN)
14919 tempguy.step=50;
14920
14921 tempguy.hrate = 16;
14922 tempguy.homing = 0;
14923 }
14924 else if(tempguy.family == eeGLEEOK)
14925 {
14926 tempguy.rate = 2;
14927 tempguy.homing = 0;
14928 tempguy.hrate = 9;
14929 tempguy.step=89;
14930 }
14931 else if(tempguy.family == eeGHINI)
14932 {
14933 tempguy.rate = 4;
14934 tempguy.hrate = 12;
14935 tempguy.step=62;
14936 tempguy.homing = 0;
14937 }
14938
14939 // Bigdig random rate fix
14940 if(tempguy.family==eeDIG && tempguy.misc10==1)
14941 {
14942 tempguy.rate = 2;
14943 }
14944 }
14945
14946
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 24) // November 2012
14947 {
14948 if(tempguy.family==eeLANM)
14949 tempguy.misc3 = 1;
14950 else if(tempguy.family==eeMOLD)
14951 tempguy.misc2 = 0;
14952 }
14953
14954
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
14955 {
14956
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 38764 times.
39424 if(tempguy.family!=eeDIG)
14957 {
14958 38764 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
14959 38764 }
14960
14961 39424 }
14962 // does not seem to solve the issue!
14963
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if ( Header->zelda_version <= 0x210 )
14964 {
14965 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
14966 if ( tempguy.family == eeDONGO )
14967 {
14968 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
14969 }
14970 }
14971
14972
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if(guyversion >= 42)
14973 {
14974
2/2
✓ Branch 0 taken 16896 times.
✓ Branch 1 taken 1024 times.
17920 if(guyversion >= 47)
14975 {
14976
1/2
✓ Branch 0 taken 16896 times.
✗ Branch 1 not taken.
16896 if(!p_igetl(&(tempguy.moveflags),f))
14977 {
14978 return qe_invalid;
14979 }
14980 16896 }
14981 else
14982 {
14983 byte fl;
14984
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&fl,f))
14985 {
14986 return qe_invalid;
14987 }
14988 1024 tempguy.moveflags = fl;
14989 }
14990 17920 }
14991 else
14992 {
14993
7/8
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 30899 times.
✓ Branch 2 taken 1202 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 518 times.
✓ Branch 5 taken 278 times.
✓ Branch 6 taken 241 times.
✓ Branch 7 taken 5840 times.
39424 switch(tempguy.family)
14994 {
14995 //No gravity; floats over pits
14996 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
14997 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
14998 //Special (bosses, etc)
14999 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15000 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15001 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15002 30899 tempguy.moveflags = FLAG_CAN_PITWALK;
15003 30899 break;
15004 //No gravity, but falls in pits
15005 case eeLEV:
15006 518 tempguy.moveflags = FLAG_CAN_PITFALL;
15007 518 break;
15008 //Bosses that respect pits
15009 case eeDONGO:
15010 278 tempguy.moveflags = FLAG_OBEYS_GRAV;
15011 278 break;
15012 case eeLANM:
15013 241 tempguy.moveflags = 0;
15014 241 break;
15015 //Gravity, floats over pits
15016 case eeWIZZ: case eeWALLM: case eeGHINI:
15017 1202 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
15018 1202 break;
15019 //Gravity and falls in pits
15020 case eeWALK:
15021
4/4
✓ Branch 0 taken 5519 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 280 times.
✓ Branch 3 taken 5239 times.
5840 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
15022 601 break;
15023 [[fallthrough]];
15024 case eeOTHER:
15025 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15026 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15027 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15028 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15029 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15030 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15031 5685 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
15032 5685 }
15033 }
15034
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if(guyversion < 43)
15035 {
15036
2/2
✓ Branch 0 taken 32101 times.
✓ Branch 1 taken 7323 times.
39424 switch(tempguy.family)
15037 {
15038 //No gravity; floats over pits
15039 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15040 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15041 //Special (bosses, etc)
15042 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15043 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15044 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15045 case eeWIZZ: case eeWALLM: case eeGHINI:
15046 //Gravity, floats over pits
15047 32101 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15048 32101 tempguy.moveflags |= FLAG_CAN_PITWALK;
15049 32101 break;
15050 }
15051 39424 }
15052
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if (guyversion < 44)
15053 {
15054
2/2
✓ Branch 0 taken 39054 times.
✓ Branch 1 taken 370 times.
39424 if ( tempguy.family == eeGHOMA )
15055 {
15056 370 tempguy.flags |= guy_fadeinstant;
15057 370 }
15058 39424 }
15059
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if (guyversion > 44)
15060 {
15061
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_getc(&(tempguy.spr_shadow),f))
15062 {
15063 return qe_invalid;
15064 }
15065
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_getc(&(tempguy.spr_death),f))
15066 {
15067 return qe_invalid;
15068 }
15069
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_getc(&(tempguy.spr_spawn),f))
15070 {
15071 return qe_invalid;
15072 }
15073 17920 }
15074 else
15075 {
15076
2/2
✓ Branch 0 taken 39271 times.
✓ Branch 1 taken 153 times.
39424 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15077 39424 tempguy.spr_death = iwDeath;
15078 39424 tempguy.spr_spawn = iwSpawn;
15079 }
15080
15081
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if(guyversion < 46)
15082 {
15083
4/4
✓ Branch 0 taken 5840 times.
✓ Branch 1 taken 33584 times.
✓ Branch 2 taken 5519 times.
✓ Branch 3 taken 321 times.
39424 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15084 {
15085 321 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15086 321 }
15087 39424 }
15088
15089
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
15090 {
15091 tempguy.script = 0;
15092 for(int q = 0; q < 8; ++q)
15093 tempguy.initD[q] = 0;
15094 }
15095 57344 guysbuf[i] = tempguy;
15096 57344 }
15097 112 }
15098
15099 112 return 0;
15100 128 }
15101
15102 void update_guy_1(guydata *tempguy) // November 2009
15103 {
15104 bool doesntcount = false;
15105 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15106
15107 switch(tempguy->family)
15108 {
15109 case 1: //eeWALK
15110 switch(tempguy->misc10)
15111 {
15112 case 0: //Stalfos
15113 if(tempguy->misc1==1) // Fires four projectiles at once
15114 tempguy->misc1=4;
15115
15116 break;
15117
15118 case 1: //Darknut
15119 goto darknuts;
15120 break;
15121 }
15122
15123 tempguy->misc10 = 0;
15124 break;
15125
15126 case 2: //eeSHOOT
15127 tempguy->family = eeWALK;
15128
15129 switch(tempguy->misc10)
15130 {
15131 case 0: //Octorok
15132 if(tempguy->misc1==1||tempguy->misc1==2)
15133 {
15134 tempguy->misc1=e1tFIREOCTO;
15135 tempguy->misc2=e2tFIREOCTO;
15136 }
15137 else tempguy->misc1 = 0;
15138
15139 tempguy->misc6=tempguy->misc4;
15140 tempguy->misc4=tempguy->misc3;
15141 tempguy->misc3=0;
15142 break;
15143
15144 case 1: // Moblin
15145 tempguy->misc1 = 0;
15146 break;
15147
15148 case 2: //Lynel
15149 tempguy->misc6=tempguy->misc1+1;
15150 tempguy->misc1=0;
15151 break;
15152
15153 case 3: //Stalfos 2
15154 if(tempguy->misc1==1) // Fires four projectiles at once
15155 tempguy->misc1=e1t4SHOTS;
15156 else tempguy->misc1 = 0;
15157
15158 break;
15159
15160 case 4: //Darknut 5
15161 darknuts:
15162 tempguy->defense[edefFIRE] = edIGNORE;
15163 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15164 tempguy->defense[edefHOOKSHOT] = 0;
15165 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15166 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15167
15168 if(tempguy->misc1==1)
15169 tempguy->misc1=2;
15170 else if(tempguy->misc1==2)
15171 {
15172 tempguy->misc4=tempguy->misc3;
15173 tempguy->misc3=tempguy->misc2;
15174 tempguy->misc2=e2tSPLIT;
15175 tempguy->misc1 = 0;
15176 }
15177 else tempguy->misc1 = 0;
15178
15179 tempguy->flags |= inv_front;
15180
15181 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15182 tempguy->flags |= guy_bkshield;
15183
15184 break;
15185 }
15186
15187 tempguy->misc10 = 0;
15188 break;
15189
15190 /*
15191 case 9: //eeARMOS
15192 tempguy->family = eeWALK;
15193 break;
15194 */
15195 case 11: //eeGEL
15196 case 33: //eeGELTRIB
15197 if(tempguy->family==33)
15198 {
15199 tempguy->misc4 = 1;
15200
15201 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15202 tempguy->misc3 = tempguy->misc2;
15203
15204 tempguy->misc2 = e2tTRIBBLE;
15205 }
15206 else
15207 {
15208 tempguy->misc4 = 0;
15209 tempguy->misc3 = 0;
15210 tempguy->misc2 = 0;
15211 }
15212
15213 tempguy->family = eeWALK;
15214
15215 if(tempguy->misc1)
15216 {
15217 tempguy->misc1=1;
15218 tempguy->weapon = ewFireTrail;
15219 }
15220
15221 break;
15222
15223 case 34: //eeZOLTRIB
15224 case 12: //eeZOL
15225 tempguy->misc4=tempguy->misc3;
15226 tempguy->misc3=tempguy->misc2;
15227 tempguy->family = eeWALK;
15228 tempguy->misc2=e2tSPLITHIT;
15229
15230 if(tempguy->misc1)
15231 {
15232 tempguy->misc1=1;
15233 tempguy->weapon = ewFireTrail;
15234 }
15235
15236 break;
15237
15238 case 13: //eeROPE
15239 tempguy->family = eeWALK;
15240 tempguy->misc9 = e9tROPE;
15241
15242 if(tempguy->misc1)
15243 {
15244 tempguy->misc4 = tempguy->misc3;
15245 tempguy->misc3 = tempguy->misc2;
15246 tempguy->misc2 = e2tBOMBCHU;
15247 }
15248
15249 tempguy->misc1 = 0;
15250 break;
15251
15252 case 14: //eeGORIYA
15253 tempguy->family = eeWALK;
15254
15255 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15256
15257 break;
15258
15259 case 17: //eeBUBBLE
15260 tempguy->family = eeWALK;
15261 tempguy->misc8 = tempguy->misc2;
15262 tempguy->misc7 = tempguy->misc1 + 1;
15263 tempguy->misc1 = tempguy->misc2 = 0;
15264
15265 //fallthrogh
15266 case eeTRAP:
15267 case eeROCK:
15268 doesntcount = true;
15269 break;
15270
15271 case 35: //eeVIRETRIB
15272 case 18: //eeVIRE
15273 tempguy->family = eeWALK;
15274 tempguy->misc4=tempguy->misc3;
15275 tempguy->misc3=tempguy->misc2;
15276 tempguy->misc2=e2tSPLITHIT;
15277 tempguy->misc9=e9tVIRE;
15278 break;
15279
15280 case 19: //eeLIKE
15281 tempguy->family = eeWALK;
15282 tempguy->misc7 = e7tEATITEMS;
15283 tempguy->misc8=95;
15284 break;
15285
15286 case 20: //eePOLSV
15287 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15288 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15289 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15290 tempguy->defense[edefARROW] = ed1HKO;
15291 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15292 tempguy->family = eeWALK;
15293 tempguy->misc9 = e9tPOLSVOICE;
15294 tempguy->rate = 4;
15295 tempguy->homing = 32;
15296 tempguy->hrate = 10;
15297 tempguy->grumble = 0;
15298 break;
15299
15300 case eeWIZZ:
15301 if(tempguy->misc4)
15302 {
15303 for(int32_t i=0; i < edefLAST; i++)
15304 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15305 }
15306 else
15307 {
15308 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15309 tempguy->defense[edefMAGIC] = edCHINK;
15310 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15311 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15312 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15313 }
15314
15315 break;
15316
15317 case eePEAHAT:
15318 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15319
15320 if(!(tempguy->flags & guy_bhit))
15321 tempguy->defense[edefBRANG] = edSTUNONLY;
15322
15323 break;
15324
15325 case eeLEV:
15326 tempguy->defense[edefSTOMP] = edCHINK;
15327 break;
15328 }
15329
15330 // Old flags
15331 if(tempguy->flags & guy_superman)
15332 {
15333 for(int32_t i = 0; i < edefLAST; i++)
15334 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15335 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15336 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15337 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15338 }
15339
15340 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15341
15342 if(doesntcount)
15343 tempguy->flags |= (guy_doesntcount);
15344 }
15345
15346
15347 247176 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version)
15348 {
15349 byte tempbyte, padding;
15350 int32_t extras, secretcombos;
15351 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->valid),f))
15353 {
15354 return qe_invalid;
15355 }
15356
15357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->guy),f))
15358 return qe_invalid;
15359 247176 temp_mapscr->guytile = -1; //signal to use default guy values
15360
2/2
✓ Branch 0 taken 246700 times.
✓ Branch 1 taken 476 times.
247176 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15361
4/4
✓ Branch 0 taken 476 times.
✓ Branch 1 taken 246700 times.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 453 times.
247176 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15362
15363
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15364 {
15365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f))
15366 {
15367 return qe_invalid;
15368 }
15369
15370 6864 temp_mapscr->str=tempbyte;
15371 6864 }
15372 else
15373 {
15374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 if(!p_igetw(&(temp_mapscr->str),f))
15375 {
15376 return qe_invalid;
15377 }
15378 }
15379
15380
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->room),f))
15381 {
15382 return qe_invalid;
15383 }
15384
15385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->item),f))
15386 {
15387 return qe_invalid;
15388 }
15389
15390
3/6
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 153408 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15391 {
15392 93768 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15393 93768 }
15394 else
15395 {
15396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->hasitem),f))
15397 return qe_invalid;
15398 }
15399
15400
2/4
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
247176 if((Header->zelda_version < 0x192)||
15401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15402 {
15403
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f))
15404 {
15405 return qe_invalid;
15406 }
15407 6864 }
15408
15409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15410 {
15411 return qe_invalid;
15412 }
15413
15414
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15415 {
15416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f))
15417 {
15418 return qe_invalid;
15419 }
15420 6864 }
15421
15422
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15423 {
15424
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15425 {
15426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15427 {
15428 return qe_invalid;
15429 }
15430 460224 }
15431 153408 }
15432 else
15433 {
15434 93768 temp_mapscr->tilewarptype[1]=0;
15435 93768 temp_mapscr->tilewarptype[2]=0;
15436 93768 temp_mapscr->tilewarptype[3]=0;
15437 }
15438
15439
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15440 {
15441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15442 {
15443 return qe_invalid;
15444 }
15445 240312 }
15446
15447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15448 {
15449 return qe_invalid;
15450 }
15451
15452 247176 temp_mapscr->warpreturnx[1]=0;
15453 247176 temp_mapscr->warpreturnx[2]=0;
15454 247176 temp_mapscr->warpreturnx[3]=0;
15455
15456
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15457 {
15458
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15459 {
15460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15461 {
15462 return qe_invalid;
15463 }
15464 460224 }
15465 153408 }
15466
15467
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15468 {
15469 return qe_invalid;
15470 }
15471
15472 247176 temp_mapscr->warpreturny[1]=0;
15473 247176 temp_mapscr->warpreturny[2]=0;
15474 247176 temp_mapscr->warpreturny[3]=0;
15475
15476
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15477 {
15478
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15479 {
15480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15481 {
15482 return qe_invalid;
15483 }
15484 460224 }
15485
15486
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(version>=18)
15487 {
15488
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15489 {
15490 return qe_invalid;
15491 }
15492 153408 }
15493 else
15494 {
15495 byte temp;
15496
15497 if(!p_getc(&temp,f))
15498 {
15499 return qe_invalid;
15500 }
15501
15502 temp_mapscr->warpreturnc=temp<<8|temp;
15503 }
15504 153408 }
15505
15506
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->stairx),f))
15507
15508 {
15509 return qe_invalid;
15510 }
15511
15512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->stairy),f))
15513 {
15514 return qe_invalid;
15515 }
15516
15517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->itemx),f))
15518 {
15519 return qe_invalid;
15520 }
15521
15522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->itemy),f))
15523 {
15524 return qe_invalid;
15525 }
15526
15527
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version > 15) // February 2009
15528 {
15529
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->color),f))
15530 {
15531 return qe_invalid;
15532 }
15533 153408 }
15534 else
15535 {
15536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93768 times.
93768 if(!p_getc(& tempbyte,f))
15537 {
15538 return qe_invalid;
15539 }
15540
15541 93768 temp_mapscr->color = (word) tempbyte;
15542 }
15543
15544
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->enemyflags),f))
15545 {
15546 return qe_invalid;
15547 }
15548
15549
2/2
✓ Branch 0 taken 988704 times.
✓ Branch 1 taken 247176 times.
1235880 for(int32_t k=0; k<4; k++)
15550 {
15551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 988704 times.
988704 if(!p_getc(&(temp_mapscr->door[k]),f))
15552 {
15553 return qe_invalid;
15554
15555 }
15556 988704 }
15557
15558
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version <= 11)
15559 {
15560
1/2
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
93768 if(!p_getc(&(tempbyte),f))
15561 {
15562 return qe_invalid;
15563 }
15564
15565 93768 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15566
15567
2/6
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93768 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15568 {
15569 for(int32_t i=1; i<4; i++)
15570 {
15571 if(!p_getc(&(tempbyte),f))
15572 {
15573 return qe_invalid;
15574 }
15575
15576 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15577 }
15578 }
15579 else
15580 {
15581 93768 temp_mapscr->tilewarpdmap[1]=0;
15582 93768 temp_mapscr->tilewarpdmap[2]=0;
15583 93768 temp_mapscr->tilewarpdmap[3]=0;
15584 }
15585 93768 }
15586 else
15587 {
15588
2/2
✓ Branch 0 taken 613632 times.
✓ Branch 1 taken 153408 times.
767040 for(int32_t i=0; i<4; i++)
15589 {
15590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 613632 times.
613632 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15591 {
15592 return qe_invalid;
15593 }
15594 613632 }
15595 }
15596
15597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15598 {
15599 return qe_invalid;
15600 }
15601
15602
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15603 {
15604
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15605 {
15606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15607 {
15608 return qe_invalid;
15609 }
15610 460224 }
15611 153408 }
15612 else
15613 {
15614 93768 temp_mapscr->tilewarpscr[1]=0;
15615 93768 temp_mapscr->tilewarpscr[2]=0;
15616 93768 temp_mapscr->tilewarpscr[3]=0;
15617 }
15618
15619
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version >= 15)
15620 {
15621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15622 {
15623 return qe_invalid;
15624 }
15625 153408 }
15626 else
15627 {
15628 93768 temp_mapscr->tilewarpoverlayflags=0;
15629 }
15630
15631
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->exitdir),f))
15632 {
15633 return qe_invalid;
15634 }
15635
15636
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15637 {
15638
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f))
15639 {
15640 return qe_invalid;
15641 }
15642
15643 6864 }
15644
15645
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15646 {
15647 if(!p_getc(&padding,f))
15648 {
15649 return qe_invalid;
15650 }
15651 }
15652
15653
2/2
✓ Branch 0 taken 2471760 times.
✓ Branch 1 taken 247176 times.
2718936 for(int32_t k=0; k<10; k++)
15654 {
15655 /*
15656 if (!temp_mapscr->enemy[k])
15657 {
15658 continue;
15659 }
15660 */
15661
3/6
✓ Branch 0 taken 2403120 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2403120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2471760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15662 {
15663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68640 times.
68640 if(!p_getc(&tempbyte,f))
15664 {
15665 return qe_invalid;
15666 }
15667
15668 68640 temp_mapscr->enemy[k]=tempbyte;
15669 68640 }
15670 else
15671 {
15672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2403120 times.
2403120 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
15673 {
15674 return qe_invalid;
15675 }
15676 }
15677
15678
3/6
✓ Branch 0 taken 2403120 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2403120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2471760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15679 {
15680 //using enumerations here is dangerous
15681 //very easy to break old quests -DD
15682
2/2
✓ Branch 0 taken 788 times.
✓ Branch 1 taken 67852 times.
68640 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15683 {
15684 788 temp_mapscr->enemy[k]+=5;
15685 788 }
15686
2/2
✓ Branch 0 taken 67812 times.
✓ Branch 1 taken 40 times.
67852 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15687 {
15688 40 temp_mapscr->enemy[k]+=1;
15689 40 }
15690 68640 }
15691
15692
2/2
✓ Branch 0 taken 1534080 times.
✓ Branch 1 taken 937680 times.
2471760 if(version < 9)
15693 {
15694
2/2
✓ Branch 0 taken 856505 times.
✓ Branch 1 taken 81175 times.
937680 if(temp_mapscr->enemy[k]>0)
15695 {
15696 81175 temp_mapscr->enemy[k]+=10;
15697 81175 }
15698 937680 }
15699 //don't read in any invalid data
15700
2/2
✓ Branch 0 taken 2471670 times.
✓ Branch 1 taken 90 times.
2471760 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15701 {
15702 90 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15703 90 temp_mapscr->enemy[k] = 0;
15704 90 }
15705 2471760 }
15706
15707
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->pattern),f))
15708 {
15709 return qe_invalid;
15710 }
15711
15712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
15713 {
15714 return qe_invalid;
15715 }
15716
15717
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15718 {
15719
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15720 {
15721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
15722 {
15723 return qe_invalid;
15724 }
15725 460224 }
15726 153408 }
15727 else
15728 {
15729 93768 temp_mapscr->sidewarptype[1]=0;
15730 93768 temp_mapscr->sidewarptype[2]=0;
15731 93768 temp_mapscr->sidewarptype[3]=0;
15732 }
15733
15734
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version >= 15)
15735 {
15736
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
15737 {
15738 return qe_invalid;
15739 }
15740 153408 }
15741 else
15742 {
15743 93768 temp_mapscr->sidewarpoverlayflags=0;
15744 }
15745
15746
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->warparrivalx),f))
15747 {
15748 return qe_invalid;
15749 }
15750
15751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->warparrivaly),f))
15752 {
15753 return qe_invalid;
15754 }
15755
15756
2/2
✓ Branch 0 taken 988704 times.
✓ Branch 1 taken 247176 times.
1235880 for(int32_t k=0; k<4; k++)
15757 {
15758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 988704 times.
988704 if(!p_getc(&(temp_mapscr->path[k]),f))
15759 {
15760 return qe_invalid;
15761 }
15762 988704 }
15763
15764
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
15765 {
15766 return qe_invalid;
15767 }
15768
15769
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15770 {
15771
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 460224 times.
613632 for(int32_t i=1; i<4; i++)
15772 {
15773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
15774 {
15775 return qe_invalid;
15776 }
15777 460224 }
15778 153408 }
15779 else
15780 {
15781 93768 temp_mapscr->sidewarpscr[1]=0;
15782 93768 temp_mapscr->sidewarpscr[2]=0;
15783 93768 temp_mapscr->sidewarpscr[3]=0;
15784 }
15785
15786
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version <= 11)
15787 {
15788
1/2
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
93768 if(!p_getc(&(tempbyte),f))
15789 {
15790 return qe_invalid;
15791 }
15792
15793 93768 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
15794
15795
2/6
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93768 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15796 {
15797 for(int32_t i=1; i<4; i++)
15798 {
15799 if(!p_getc(&(tempbyte),f))
15800 {
15801 return qe_invalid;
15802 }
15803
15804 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
15805 }
15806 }
15807 else
15808 {
15809 93768 temp_mapscr->sidewarpdmap[1]=0;
15810 93768 temp_mapscr->sidewarpdmap[2]=0;
15811 93768 temp_mapscr->sidewarpdmap[3]=0;
15812 }
15813 93768 }
15814 else
15815 {
15816
2/2
✓ Branch 0 taken 613632 times.
✓ Branch 1 taken 153408 times.
767040 for(int32_t i=0; i<4; i++)
15817 {
15818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 613632 times.
613632 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
15819 {
15820 return qe_invalid;
15821 }
15822 613632 }
15823 }
15824
15825
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15826 {
15827
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
15828 {
15829 return qe_invalid;
15830 }
15831 153408 }
15832 93768 else temp_mapscr->sidewarpindex = 0;
15833
15834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_igetw(&(temp_mapscr->undercombo),f))
15835 {
15836 return qe_invalid;
15837 }
15838
15839
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15840 {
15841
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&(temp_mapscr->old_cpage),f))
15842 {
15843 return qe_invalid;
15844 }
15845 6864 }
15846
15847
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
15848 {
15849 return qe_invalid;
15850 }
15851
15852
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_igetw(&(temp_mapscr->catchall),f))
15853 {
15854 return qe_invalid;
15855 }
15856
15857
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->flags),f))
15858 {
15859 return qe_invalid;
15860 }
15861
15862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->flags2),f))
15863 {
15864 return qe_invalid;
15865 }
15866
15867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->flags3),f))
15868 {
15869 return qe_invalid;
15870 }
15871
15872
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
15873 //if (version>2)
15874 {
15875
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags4),f))
15876 {
15877 return qe_invalid;
15878 }
15879 153408 }
15880
15881
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15882 {
15883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags5),f))
15884 {
15885 return qe_invalid;
15886 }
15887
15888
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->noreset),f))
15889 {
15890 return qe_invalid;
15891 }
15892
15893
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->nocarry),f))
15894 {
15895 return qe_invalid;
15896 }
15897
15898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(temp_mapscr->flags5&32)
15899 {
15900 temp_mapscr->flags5 &= ~32;
15901 temp_mapscr->noreset |= 48;
15902 }
15903
15904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(version<8)
15905 {
15906 if(temp_mapscr->noreset&1)
15907 {
15908 temp_mapscr->noreset|=8192;
15909 }
15910
15911 if(temp_mapscr->nocarry&1)
15912 {
15913 temp_mapscr->nocarry|=8192;
15914 temp_mapscr->nocarry&=~1;
15915 }
15916 }
15917 153408 }
15918 else
15919 {
15920 93768 temp_mapscr->flags5 = 0;
15921 93768 temp_mapscr->noreset = 0;
15922 93768 temp_mapscr->nocarry = 0;
15923 }
15924
15925
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
15926 {
15927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags6),f))
15928 {
15929 return qe_invalid;
15930 }
15931 153408 }
15932
15933
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>5)
15934 {
15935
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags7),f))
15936 {
15937 return qe_invalid;
15938 }
15939
15940
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags8),f))
15941 {
15942 return qe_invalid;
15943 }
15944
15945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags9),f))
15946 {
15947 return qe_invalid;
15948 }
15949
15950
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags10),f))
15951 {
15952 return qe_invalid;
15953 }
15954
15955
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->csensitive),f))
15956 {
15957 return qe_invalid;
15958 }
15959 153408 }
15960 else
15961 {
15962 93768 temp_mapscr->csensitive=1;
15963 }
15964
15965
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version<14) // August 2007: screen SFX added
15966 {
15967
2/2
✓ Branch 0 taken 93668 times.
✓ Branch 1 taken 100 times.
93768 if(temp_mapscr->flags&8) //fROAR
15968 {
15969 100 temp_mapscr->bosssfx=
15970
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 91 times.
100 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
15971 91 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
15972 WAV_ROAR;
15973 100 }
15974
15975
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 93677 times.
93768 if(temp_mapscr->flags&128) //fSEA
15976 {
15977 91 temp_mapscr->oceansfx=WAV_SEA;
15978 91 }
15979
15980 93768 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
15981 ? 0 : WAV_SECRET;
15982
15983 93768 temp_mapscr->flags3 &= ~66; //64|2
15984 93768 temp_mapscr->flags2 &= ~32;
15985 93768 temp_mapscr->flags &= ~136; // 128|8
15986 93768 }
15987 else
15988 {
15989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->oceansfx),f))
15990 {
15991 return qe_invalid;
15992 }
15993
15994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->bosssfx),f))
15995 {
15996 return qe_invalid;
15997 }
15998
15999
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->secretsfx),f))
16000 {
16001 return qe_invalid;
16002 }
16003 }
16004
16005
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version<15) // October 2007: another SFX
16006 {
16007 93768 temp_mapscr->holdupsfx=WAV_PICKUP;
16008 93768 }
16009 else
16010 {
16011
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->holdupsfx),f))
16012 {
16013 return qe_invalid;
16014 }
16015 }
16016
16017
16018
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16019 {
16020
2/2
✓ Branch 0 taken 1441872 times.
✓ Branch 1 taken 240312 times.
1682184 for(int32_t k=0; k<6; k++)
16021 {
16022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16023 {
16024 return qe_invalid;
16025 }
16026 1441872 }
16027
16028
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 1441872 times.
1682184 for(int32_t k=0; k<6; k++)
16029 {
16030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16031 {
16032 return qe_invalid;
16033 }
16034 1441872 }
16035 240312 }
16036
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6864 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16037 {
16038 if(!p_getc(&(temp_mapscr->layermap[2]),f))
16039 {
16040 return qe_invalid;
16041 }
16042
16043 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
16044 {
16045 return qe_invalid;
16046 }
16047
16048 if(!p_getc(&(temp_mapscr->layermap[4]),f))
16049 {
16050 return qe_invalid;
16051 }
16052
16053 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
16054
16055 {
16056 return qe_invalid;
16057 }
16058 }
16059
16060
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>149))
16061 {
16062 for(int32_t k=0; k<6; k++)
16063 {
16064 if(!p_getc(&tempbyte,f)) //layerxsize
16065 {
16066 return qe_invalid;
16067 }
16068 }
16069
16070 for(int32_t k=0; k<6; k++)
16071 {
16072 if(!p_getc(&tempbyte,f)) //layerxspeed
16073 {
16074 return qe_invalid;
16075 }
16076 }
16077
16078 for(int32_t k=0; k<6; k++)
16079 {
16080 if(!p_getc(&tempbyte,f)) //layerxdelay
16081 {
16082 return qe_invalid;
16083 }
16084 }
16085
16086 for(int32_t k=0; k<6; k++)
16087 {
16088 if(!p_getc(&tempbyte,f)) //layerysize
16089 {
16090 return qe_invalid;
16091 }
16092 }
16093
16094 for(int32_t k=0; k<6; k++)
16095 {
16096 if(!p_getc(&tempbyte,f)) //layeryspeed
16097 {
16098 return qe_invalid;
16099 }
16100 }
16101
16102 for(int32_t k=0; k<6; k++)
16103 {
16104 if(!p_getc(&tempbyte,f)) //layerydelay
16105 {
16106 return qe_invalid;
16107 }
16108 }
16109 }
16110
16111
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16112 {
16113
2/2
✓ Branch 0 taken 1441872 times.
✓ Branch 1 taken 240312 times.
1682184 for(int32_t k=0; k<6; k++)
16114 {
16115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16116 {
16117 return qe_invalid;
16118 }
16119 1441872 }
16120 240312 }
16121
16122
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16123 {
16124
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 if((Header->zelda_version == 0x192)&&(Header->build>153))
16125 {
16126 if(!p_getc(&padding,f))
16127 {
16128 return qe_invalid;
16129 }
16130 }
16131
16132
1/2
✓ Branch 0 taken 240312 times.
✗ Branch 1 not taken.
240312 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16133 {
16134 return qe_invalid;
16135 }
16136 240312 }
16137
16138
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16139 {
16140 6864 extras=15;
16141 6864 }
16142
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16143 {
16144 extras=11;
16145 }
16146
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16147 {
16148 extras=32;
16149 }
16150
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16151 {
16152 extras=64;
16153 }
16154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 else if(Header->zelda_version < 0x193)
16155 {
16156 extras=62;
16157 }
16158 else
16159
16160 {
16161 240312 extras=0;
16162 }
16163
16164
2/2
✓ Branch 0 taken 102960 times.
✓ Branch 1 taken 247176 times.
350136 for(int32_t k=0; k<extras; k++)
16165 {
16166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102960 times.
102960 if(!p_getc(&tempbyte,f)) //extra[k]
16167 {
16168 return qe_invalid;
16169 }
16170 102960 }
16171
16172
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16173 //if (version>3)
16174 {
16175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->nextmap),f))
16176 {
16177 return qe_invalid;
16178 }
16179
16180
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->nextscr),f))
16181 {
16182 return qe_invalid;
16183 }
16184 153408 }
16185 else
16186 {
16187 93768 temp_mapscr->nextmap=0;
16188 93768 temp_mapscr->nextscr=0;
16189 }
16190
16191
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16192 {
16193 6864 secretcombos=20;
16194 6864 }
16195
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16196 {
16197 secretcombos=256;
16198 }
16199 else
16200 {
16201 240312 secretcombos=128;
16202 }
16203
16204
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16205 {
16206
2/2
✓ Branch 0 taken 137280 times.
✓ Branch 1 taken 6864 times.
144144 for(int32_t k=0; k<secretcombos; k++)
16207 {
16208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(!p_getc(&tempbyte,f))
16209 {
16210 return qe_invalid;
16211 }
16212
16213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(k<128)
16214 {
16215 137280 temp_mapscr->secretcombo[k]=tempbyte;
16216 137280 }
16217 137280 }
16218 6864 }
16219 else
16220 {
16221
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16222 {
16223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16224 {
16225 return qe_invalid;
16226 }
16227
16228 30759936 }
16229 }
16230
16231
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16232 {
16233
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16234 {
16235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16236 {
16237 return qe_invalid;
16238 }
16239 30759936 }
16240
16241
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16242 {
16243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16244 {
16245 return qe_invalid;
16246 }
16247 30759936 }
16248 240312 }
16249
16250
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16251 {
16252 if(!p_getc(&padding,f))
16253 {
16254 return qe_invalid;
16255 }
16256 }
16257
16258
2/2
✓ Branch 0 taken 43502976 times.
✓ Branch 1 taken 247176 times.
43750152 for(int32_t k=0; k<176; k++)
16259 {
16260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43502976 times.
43502976 if(!p_igetw(&(temp_mapscr->data[k]),f))
16261 {
16262 return qe_invalid;
16263 }
16264 43502976 }
16265
16266
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16267 {
16268 if(!p_getc(&padding,f))
16269 {
16270 return qe_invalid;
16271 }
16272
16273 if(!p_getc(&padding,f))
16274 {
16275 return qe_invalid;
16276 }
16277 }
16278
16279
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16280 {
16281
2/2
✓ Branch 0 taken 42294912 times.
✓ Branch 1 taken 240312 times.
42535224 for(int32_t k=0; k<176; k++)
16282 {
16283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
42294912 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16284 {
16285 return qe_invalid;
16286 }
16287
16288
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42294912 if((Header->zelda_version == 0x192)&&(Header->build<24))
16289 {
16290 if(!p_getc(&tempbyte,f))
16291 {
16292 return qe_invalid;
16293 }
16294
16295 if(!p_getc(&tempbyte,f))
16296 {
16297 return qe_invalid;
16298 }
16299
16300 if(!p_getc(&tempbyte,f))
16301 {
16302 return qe_invalid;
16303 }
16304 }
16305 42294912 }
16306 240312 }
16307
16308
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16309 {
16310
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 42294912 times.
42535224 for(int32_t k=0; k<176; k++)
16311 {
16312
16313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
42294912 if(!p_getc(&(temp_mapscr->cset[k]),f))
16314 {
16315 return qe_invalid;
16316 }
16317 42294912 }
16318 240312 }
16319
16320
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16321 {
16322 6864 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16323 6864 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16324 6864 }
16325
16326
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16327 {
16328 6864 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16329 6864 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16330 6864 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16331 6864 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16332 6864 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16333 6864 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16334 6864 }
16335
16336
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16337 {
16338
2/2
✓ Branch 0 taken 1208064 times.
✓ Branch 1 taken 6864 times.
1214928 for(int32_t k=0; k<176; k++)
16339 {
16340
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version == 0x192)&&(Header->build>149))
16341 {
16342 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16343 {
16344 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16345 }
16346 }
16347 else
16348 {
16349
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version < 0x192)||
16350 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16351 {
16352 1208064 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16353 1208064 }
16354
16355 1208064 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16356 }
16357
16358 1208064 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16359 1208064 }
16360 6864 }
16361
16362 /*if(version>12)
16363 {
16364 if(!p_getc(&(temp_mapscr->scrWidth),f))
16365 {
16366 return qe_invalid;
16367 }
16368 if(!p_getc(&(temp_mapscr->scrHeight),f))
16369 {
16370 return qe_invalid;
16371 }
16372 }*/
16373
16374
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>4)
16375 {
16376
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16377 {
16378 return qe_invalid;
16379 }
16380 153408 }
16381 else
16382 {
16383 93768 temp_mapscr->screen_midi = -1;
16384 }
16385
16386
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>=17)
16387 {
16388
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->lens_layer),f))
16389 {
16390 return qe_invalid;
16391 }
16392 153408 }
16393 else
16394 {
16395 93768 temp_mapscr->lens_layer = llNORMAL;
16396 }
16397
16398
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version>6)
16399 {
16400 dword bits;
16401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_igetl(&bits,f))
16402 {
16403 return qe_invalid;
16404 }
16405
16406 int32_t m;
16407 float tempfloat;
16408 word tempw;
16409 153408 temp_mapscr->ffcCountMarkDirty();
16410
16411
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 4909056 times.
5062464 for(m=0; m<32; m++)
16412 {
16413 4909056 ffcdata& tempffc = temp_mapscr->ffcs[m];
16414 4909056 tempffc.clear();
16415
2/2
✓ Branch 0 taken 4886067 times.
✓ Branch 1 taken 22989 times.
4909056 if((bits>>m)&1)
16416 {
16417
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(!p_igetw(&tempw,f))
16418 {
16419 return qe_invalid;
16420 }
16421 22989 tempffc.setData(tempw);
16422
16423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempffc.cset),f))
16424 {
16425 return qe_invalid;
16426 }
16427
16428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetw(&(tempffc.delay),f))
16429 {
16430 return qe_invalid;
16431 }
16432
16433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(version < 9)
16434 {
16435 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16436 {
16437 return qe_invalid;
16438 }
16439
16440 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16441
16442 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16443 {
16444 return qe_invalid;
16445 }
16446
16447 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16448
16449 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16450 {
16451 return qe_invalid;
16452 }
16453
16454 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16455
16456 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16457 {
16458 return qe_invalid;
16459 }
16460
16461 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16462
16463 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16464 {
16465 return qe_invalid;
16466 }
16467
16468 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16469
16470 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16471 {
16472 return qe_invalid;
16473 }
16474
16475 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16476 }
16477 else
16478 {
16479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.x),f))
16480 {
16481 return qe_invalid;
16482 }
16483
16484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.y),f))
16485 {
16486 return qe_invalid;
16487 }
16488
16489
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(!p_igetzf(&(tempffc.vx),f))
16490 {
16491 return qe_invalid;
16492 }
16493
16494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.vy),f))
16495 {
16496 return qe_invalid;
16497 }
16498
16499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.ax),f))
16500 {
16501 return qe_invalid;
16502 }
16503
16504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.ay),f))
16505 {
16506 return qe_invalid;
16507 }
16508 }
16509
16510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempffc.link),f))
16511 {
16512 return qe_invalid;
16513 }
16514
16515
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>7)
16516 {
16517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&tempbyte,f))
16518 {
16519 return qe_invalid;
16520 }
16521
16522 22989 tempffc.hit_width = (tempbyte&0x3F)+1;
16523 22989 tempffc.txsz = (tempbyte>>6)+1;
16524
16525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&tempbyte,f))
16526 {
16527 return qe_invalid;
16528 }
16529
16530 22989 tempffc.hit_height = (tempbyte&0x3F)+1;
16531 22989 tempffc.tysz = (tempbyte>>6)+1;
16532
16533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.flags),f))
16534 {
16535 return qe_invalid;
16536 }
16537 22989 }
16538 else
16539 {
16540 tempffc.hit_width=16;
16541 tempffc.hit_height=16;
16542 tempffc.txsz=1;
16543 tempffc.tysz=1;
16544 tempffc.flags=0;
16545 }
16546
16547 22989 tempffc.updateSolid();
16548
16549
16550
4/6
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20969 times.
✓ Branch 3 taken 2020 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 20969 times.
22989 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16551 {
16552 tempffc.flags|=ffIGNOREHOLDUP;
16553 }
16554
16555
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>9)
16556 {
16557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetw(&(tempffc.script),f))
16558 {
16559 return qe_invalid;
16560 }
16561 22989 }
16562 else
16563 {
16564 tempffc.script=0;
16565 }
16566
16567
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>10)
16568 {
16569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[0]),f))
16570 {
16571 return qe_invalid;
16572 }
16573
16574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[1]),f))
16575 {
16576 return qe_invalid;
16577 }
16578
16579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[2]),f))
16580 {
16581 return qe_invalid;
16582 }
16583
16584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[3]),f))
16585 {
16586 return qe_invalid;
16587 }
16588
16589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[4]),f))
16590 {
16591 return qe_invalid;
16592 }
16593
16594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[5]),f))
16595 {
16596 return qe_invalid;
16597 }
16598
16599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[6]),f))
16600 {
16601 return qe_invalid;
16602 }
16603
16604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[7]),f))
16605 {
16606 return qe_invalid;
16607 }
16608
16609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempbyte),f))
16610 {
16611 return qe_invalid;
16612 }
16613
16614 22989 tempffc.inita[0]=tempbyte*10000;
16615
16616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempbyte),f))
16617 {
16618 return qe_invalid;
16619 }
16620
16621 22989 tempffc.inita[1]=tempbyte*10000;
16622 22989 }
16623 else
16624 {
16625 tempffc.inita[0] = 10000;
16626 tempffc.inita[1] = 10000;
16627 }
16628
16629
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
16630 {
16631 tempffc.script = 0;
16632 for(int q = 0; q < 8; ++q)
16633 tempffc.initd[q] = 0;
16634 }
16635
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version <= 11)
16636 {
16637 fixffcs=true;
16638 }
16639 22989 }
16640 4909056 }
16641
2/2
✓ Branch 0 taken 14727168 times.
✓ Branch 1 taken 153408 times.
14880576 for(m = 32; m < MAXFFCS; ++m)
16642 {
16643 14727168 temp_mapscr->ffcs[m].clear();
16644 14727168 }
16645 153408 }
16646
16647 //add in the new whistle flags
16648
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version<13)
16649 {
16650
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 93749 times.
93768 if(temp_mapscr->flags & fWHISTLE)
16651 {
16652 19 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16653 19 }
16654 93768 }
16655
16656 //2.55 starts here
16657
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 19 && Header->zelda_version > 0x253 )
16658 {
16659
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16660 {
16661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
16662 {
16663 return qe_invalid;
16664 }
16665 137360 }
16666
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16667 {
16668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
16669 {
16670 return qe_invalid;
16671 }
16672 137360 }
16673
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16674 {
16675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
16676 {
16677 return qe_invalid;
16678 }
16679 137360 }
16680
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 137360 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16681 {
16682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
16683 {
16684 return qe_invalid;
16685 }
16686 137360 }
16687 13736 }
16688
3/4
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 233440 times.
247176 if ( version < 19 && Header->zelda_version > 0x253 )
16689 {
16690 for ( int32_t q = 0; q < 10; q++ )
16691 {
16692 temp_mapscr->npcstrings[q] = 0;
16693 temp_mapscr->new_items[q] = 0;
16694 temp_mapscr->new_item_x[q] = 0;
16695 temp_mapscr->new_item_y[q] = 0;
16696 }
16697 }
16698
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 20 && Header->zelda_version > 0x253 )
16699 {
16700
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_igetw(&(temp_mapscr->script),f))
16701 {
16702 return qe_invalid;
16703 }
16704
2/2
✓ Branch 0 taken 109888 times.
✓ Branch 1 taken 13736 times.
123624 for ( int32_t q = 0; q < 8; q++)
16705 {
16706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109888 times.
109888 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16707 {
16708 return qe_invalid;
16709 }
16710 109888 }
16711 13736 }
16712
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
247176 if ( version < 20 )
16713 {
16714 233440 temp_mapscr->script = 0;
16715
2/2
✓ Branch 0 taken 1867520 times.
✓ Branch 1 taken 233440 times.
2100960 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16716 233440 }
16717
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 21 && Header->zelda_version > 0x253 )
16718 {
16719
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->preloadscript),f))
16720 {
16721 return qe_invalid;
16722 }
16723 13736 }
16724
2/2
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
247176 if ( version < 21 )
16725 {
16726 233440 temp_mapscr->preloadscript = 0;
16727 233440 }
16728 //all builds with version > 20 need this. -Z
16729
16730
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16731 {
16732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13736 times.
13736 if(!p_getc(&(temp_mapscr->hidelayers ),f))
16733 {
16734 return qe_invalid;
16735 }
16736
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
16737 {
16738 return qe_invalid;
16739 }
16740 13736 }
16741
2/2
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
247176 if ( version < 22 )
16742 {
16743 233440 temp_mapscr->hidelayers = 0;
16744 233440 temp_mapscr->hidescriptlayers = 0;
16745 233440 }
16746
16747 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16748 //May be any version before 2.11. -Z
16749 /* --not the roar, the HIT SFX
16750 if ( Header->zelda_version <= 0x210 )
16751 {
16752 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16753 {
16754 temp_mapscr->bosssfx = WAV_ROAR;
16755 }
16756 }
16757 */
16758
16759 247176 return 0;
16760 247176 }
16761 263360 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
16762 {
16763
2/2
✓ Branch 0 taken 247176 times.
✓ Branch 1 taken 16184 times.
263360 if(version < 23)
16764 {
16765 247176 auto ret = readmapscreen_old(f,Header,temp_mapscr,version);
16766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(ret) return ret;
16767 247176 }
16768 else
16769 {
16770
1/2
✓ Branch 0 taken 16184 times.
✗ Branch 1 not taken.
16184 if(!p_getc(&(temp_mapscr->valid),f))
16771 return qe_invalid;
16772
2/2
✓ Branch 0 taken 10147 times.
✓ Branch 1 taken 6037 times.
16184 if(!(temp_mapscr->valid & mVALID))
16773 {
16774 10147 int map = scrind/MAPSCRS;
16775 10147 int scr = scrind%MAPSCRS;
16776
4/6
✓ Branch 0 taken 6336 times.
✓ Branch 1 taken 3811 times.
✓ Branch 2 taken 6336 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6336 times.
✗ Branch 5 not taken.
10147 if(version > 25 && scrind > -1 && (map*6+5) < map_autolayers.size())
16777 {
16778 //Empty screen, apply autolayers
16779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6336 times.
6336 for(int q = 0; q < 6; ++q)
16780 {
16781 auto layermap = map_autolayers[map*6+q];
16782 temp_mapscr->layermap[q] = layermap;
16783 if(layermap)
16784 temp_mapscr->layerscreen[q] = scr;
16785 }
16786 6336 }
16787 10147 return 0;
16788 }
16789 uint32_t scr_has_flags;
16790
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 if(!p_igetl(&scr_has_flags,f))
16791 return qe_invalid;
16792
16793
2/2
✓ Branch 0 taken 5241 times.
✓ Branch 1 taken 796 times.
6037 if(scr_has_flags & SCRHAS_ROOMDATA)
16794 {
16795
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if(!p_getc(&(temp_mapscr->guy),f))
16796 return qe_invalid;
16797
2/2
✓ Branch 0 taken 736 times.
✓ Branch 1 taken 60 times.
796 if(version > 26)
16798 {
16799
1/2
✓ Branch 0 taken 736 times.
✗ Branch 1 not taken.
736 if(!p_igetl(&(temp_mapscr->guytile),f))
16800 return qe_invalid;
16801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 736 times.
736 if(!p_getc(&(temp_mapscr->guycs),f))
16802 return qe_invalid;
16803
1/2
✓ Branch 0 taken 736 times.
✗ Branch 1 not taken.
736 if(!p_igetw(&(temp_mapscr->roomflags),f))
16804 return qe_invalid;
16805 736 }
16806 else
16807 {
16808 60 temp_mapscr->guytile = -1; //signal to use default guy values
16809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
16810
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
60 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
16811 }
16812
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if(!p_igetw(&(temp_mapscr->str),f))
16813 return qe_invalid;
16814
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if(!p_getc(&(temp_mapscr->room),f))
16815 return qe_invalid;
16816
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if(!p_igetw(&(temp_mapscr->catchall),f))
16817 return qe_invalid;
16818 796 }
16819
2/2
✓ Branch 0 taken 5916 times.
✓ Branch 1 taken 121 times.
6037 if(scr_has_flags & SCRHAS_ITEM)
16820 {
16821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
121 if(!p_getc(&(temp_mapscr->item),f))
16822 return qe_invalid;
16823
1/2
✓ Branch 0 taken 121 times.
✗ Branch 1 not taken.
121 if(!p_getc(&(temp_mapscr->hasitem),f))
16824 return qe_invalid;
16825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
121 if(!p_getc(&(temp_mapscr->itemx),f))
16826 return qe_invalid;
16827
1/2
✓ Branch 0 taken 121 times.
✗ Branch 1 not taken.
121 if(!p_getc(&(temp_mapscr->itemy),f))
16828 return qe_invalid;
16829 121 }
16830
2/2
✓ Branch 0 taken 5681 times.
✓ Branch 1 taken 356 times.
6037 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
16831 {
16832
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 if(!p_igetw(&temp_mapscr->warpreturnc,f))
16833 return qe_invalid;
16834 356 }
16835
2/2
✓ Branch 0 taken 5794 times.
✓ Branch 1 taken 243 times.
6037 if(scr_has_flags & SCRHAS_TWARP)
16836 {
16837
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 243 times.
1215 for(int32_t i=0; i<4; i++)
16838 {
16839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 972 times.
972 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
16840 return qe_invalid;
16841 972 }
16842
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 243 times.
1215 for(int32_t i=0; i<4; i++)
16843 {
16844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 972 times.
972 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
16845 return qe_invalid;
16846 972 }
16847
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 243 times.
1215 for(int32_t i=0; i<4; i++)
16848 {
16849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 972 times.
972 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
16850 return qe_invalid;
16851 972 }
16852
1/2
✓ Branch 0 taken 243 times.
✗ Branch 1 not taken.
243 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
16853 return qe_invalid;
16854 243 }
16855
2/2
✓ Branch 0 taken 5898 times.
✓ Branch 1 taken 139 times.
6037 if(scr_has_flags & SCRHAS_SWARP)
16856 {
16857
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
16858 {
16859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
16860 return qe_invalid;
16861 556 }
16862
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
16863 {
16864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16865 return qe_invalid;
16866 556 }
16867
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
16868 {
16869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
16870 return qe_invalid;
16871 556 }
16872
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
16873 return qe_invalid;
16874
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16875 return qe_invalid;
16876 139 }
16877
2/2
✓ Branch 0 taken 5605 times.
✓ Branch 1 taken 432 times.
6037 if(scr_has_flags & SCRHAS_WARPRET)
16878 {
16879
2/2
✓ Branch 0 taken 1728 times.
✓ Branch 1 taken 432 times.
2160 for(int32_t i=0; i<4; i++)
16880 {
16881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1728 times.
1728 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
16882 return qe_invalid;
16883 1728 }
16884
2/2
✓ Branch 0 taken 1728 times.
✓ Branch 1 taken 432 times.
2160 for(int32_t i=0; i<4; i++)
16885 {
16886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1728 times.
1728 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
16887 return qe_invalid;
16888 1728 }
16889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 432 times.
432 if(!p_getc(&(temp_mapscr->warparrivalx),f))
16890 return qe_invalid;
16891
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
432 if(!p_getc(&(temp_mapscr->warparrivaly),f))
16892 return qe_invalid;
16893 432 }
16894
2/2
✓ Branch 0 taken 4911 times.
✓ Branch 1 taken 1126 times.
6037 if(scr_has_flags & SCRHAS_LAYERS)
16895 {
16896
2/2
✓ Branch 0 taken 6756 times.
✓ Branch 1 taken 1126 times.
7882 for(int32_t k=0; k<6; k++)
16897 {
16898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6756 times.
6756 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16899 return qe_invalid;
16900 6756 }
16901
2/2
✓ Branch 0 taken 6756 times.
✓ Branch 1 taken 1126 times.
7882 for(int32_t k=0; k<6; k++)
16902 {
16903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6756 times.
6756 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16904 return qe_invalid;
16905 6756 }
16906
2/2
✓ Branch 0 taken 6756 times.
✓ Branch 1 taken 1126 times.
7882 for(int32_t k=0; k<6; k++)
16907 {
16908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6756 times.
6756 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16909 return qe_invalid;
16910 6756 }
16911
1/2
✓ Branch 0 taken 1126 times.
✗ Branch 1 not taken.
1126 if(!p_getc(&(temp_mapscr->hidelayers),f))
16912 return qe_invalid;
16913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1126 times.
1126 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
16914 return qe_invalid;
16915 1126 }
16916
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 if(scr_has_flags & SCRHAS_MAZE)
16917 {
16918 for(int32_t k=0; k<4; k++)
16919 {
16920 if(!p_getc(&(temp_mapscr->path[k]),f))
16921 return qe_invalid;
16922 }
16923 if(!p_getc(&(temp_mapscr->exitdir),f))
16924 return qe_invalid;
16925 }
16926
2/2
✓ Branch 0 taken 5884 times.
✓ Branch 1 taken 153 times.
6037 if(scr_has_flags & SCRHAS_D_S_U)
16927 {
16928
1/2
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
153 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
16929 return qe_invalid;
16930
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 153 times.
765 for(int32_t k=0; k<4; k++)
16931 {
16932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if(!p_getc(&(temp_mapscr->door[k]),f))
16933 return qe_invalid;
16934 612 }
16935
16936
1/2
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
153 if(!p_getc(&(temp_mapscr->stairx),f))
16937 return qe_invalid;
16938
16939
1/2
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
153 if(!p_getc(&(temp_mapscr->stairy),f))
16940 return qe_invalid;
16941
1/2
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
153 if(!p_igetw(&(temp_mapscr->undercombo),f))
16942 return qe_invalid;
16943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153 times.
153 if(!p_getc(&(temp_mapscr->undercset),f))
16944 return qe_invalid;
16945 153 }
16946
2/2
✓ Branch 0 taken 5604 times.
✓ Branch 1 taken 433 times.
6037 if(scr_has_flags & SCRHAS_FLAGS)
16947 {
16948
1/2
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
433 if(!p_getc(&(temp_mapscr->flags),f))
16949 return qe_invalid;
16950
1/2
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
433 if(!p_getc(&(temp_mapscr->flags2),f))
16951 return qe_invalid;
16952
1/2
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
433 if(!p_getc(&(temp_mapscr->flags3),f))
16953 return qe_invalid;
16954
1/2
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
433 if(!p_getc(&(temp_mapscr->flags4),f))
16955 return qe_invalid;
16956
1/2
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
433 if(!p_getc(&(temp_mapscr->flags5),f))
16957 return qe_invalid;
16958
1/2
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
433 if(!p_getc(&(temp_mapscr->flags6),f))
16959 return qe_invalid;
16960
1/2
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
433 if(!p_getc(&(temp_mapscr->flags7),f))
16961 return qe_invalid;
16962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 if(!p_getc(&(temp_mapscr->flags8),f))
16963 return qe_invalid;
16964
1/2
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
433 if(!p_getc(&(temp_mapscr->flags9),f))
16965 return qe_invalid;
16966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 if(!p_getc(&(temp_mapscr->flags10),f))
16967 return qe_invalid;
16968
1/2
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
433 if(!p_getc(&(temp_mapscr->enemyflags),f))
16969 return qe_invalid;
16970 433 }
16971
2/2
✓ Branch 0 taken 5660 times.
✓ Branch 1 taken 377 times.
6037 if(scr_has_flags & SCRHAS_ENEMY)
16972 {
16973
2/2
✓ Branch 0 taken 3770 times.
✓ Branch 1 taken 377 times.
4147 for(int32_t k=0; k<10; k++)
16974 {
16975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3770 times.
3770 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
16976 return qe_invalid;
16977
1/2
✓ Branch 0 taken 3770 times.
✗ Branch 1 not taken.
3770 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
16978 temp_mapscr->enemy[k] = 0;
16979 3770 }
16980
1/2
✓ Branch 0 taken 377 times.
✗ Branch 1 not taken.
377 if(!p_getc(&(temp_mapscr->pattern),f))
16981 return qe_invalid;
16982 377 }
16983
2/2
✓ Branch 0 taken 6004 times.
✓ Branch 1 taken 33 times.
6037 if(scr_has_flags & SCRHAS_CARRY)
16984 {
16985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(!p_igetw(&(temp_mapscr->noreset),f))
16986 return qe_invalid;
16987
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_igetw(&(temp_mapscr->nocarry),f))
16988 return qe_invalid;
16989
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_getc(&(temp_mapscr->nextmap),f))
16990 return qe_invalid;
16991
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_getc(&(temp_mapscr->nextscr),f))
16992 return qe_invalid;
16993 33 }
16994
2/2
✓ Branch 0 taken 5970 times.
✓ Branch 1 taken 67 times.
6037 if(scr_has_flags & SCRHAS_SCRIPT)
16995 {
16996
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!p_igetw(&(temp_mapscr->script),f))
16997 return qe_invalid;
16998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(!p_getc(&(temp_mapscr->preloadscript),f))
16999 return qe_invalid;
17000
2/2
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 67 times.
603 for ( int32_t q = 0; q < 8; q++ )
17001 {
17002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 536 times.
536 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
17003 return qe_invalid;
17004 536 }
17005 67 }
17006
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 if(scr_has_flags & SCRHAS_UNUSED)
17007 {
17008 for ( int32_t q = 0; q < 10; q++ )
17009 {
17010 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
17011 return qe_invalid;
17012 }
17013 for ( int32_t q = 0; q < 10; q++ )
17014 {
17015 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
17016 return qe_invalid;
17017 }
17018 for ( int32_t q = 0; q < 10; q++ )
17019 {
17020 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
17021 return qe_invalid;
17022 }
17023 for ( int32_t q = 0; q < 10; q++ )
17024 {
17025 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
17026 return qe_invalid;
17027 }
17028 }
17029
2/2
✓ Branch 0 taken 5620 times.
✓ Branch 1 taken 417 times.
6037 if(scr_has_flags & SCRHAS_SECRETS)
17030 {
17031
2/2
✓ Branch 0 taken 53376 times.
✓ Branch 1 taken 417 times.
53793 for(int32_t k=0; k<128; k++)
17032 {
17033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53376 times.
53376 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
17034 return qe_invalid;
17035 53376 }
17036
2/2
✓ Branch 0 taken 53376 times.
✓ Branch 1 taken 417 times.
53793 for(int32_t k=0; k<128; k++)
17037 {
17038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53376 times.
53376 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
17039 return qe_invalid;
17040 53376 }
17041
2/2
✓ Branch 0 taken 53376 times.
✓ Branch 1 taken 417 times.
53793 for(int32_t k=0; k<128; k++)
17042 {
17043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53376 times.
53376 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
17044 return qe_invalid;
17045 53376 }
17046 417 }
17047
2/2
✓ Branch 0 taken 2945 times.
✓ Branch 1 taken 3092 times.
6037 if(scr_has_flags & SCRHAS_COMBOFLAG)
17048 {
17049
2/2
✓ Branch 0 taken 544192 times.
✓ Branch 1 taken 3092 times.
547284 for(int32_t k=0; k<176; ++k)
17050 {
17051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 544192 times.
544192 if(!p_igetw(&(temp_mapscr->data[k]),f))
17052 return qe_invalid;
17053 544192 }
17054
2/2
✓ Branch 0 taken 544192 times.
✓ Branch 1 taken 3092 times.
547284 for(int32_t k=0; k<176; ++k)
17055 {
17056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 544192 times.
544192 if(!p_getc(&(temp_mapscr->sflag[k]),f))
17057 return qe_invalid;
17058 544192 }
17059
2/2
✓ Branch 0 taken 544192 times.
✓ Branch 1 taken 3092 times.
547284 for(int32_t k=0; k<176; ++k)
17060 {
17061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 544192 times.
544192 if(!p_getc(&(temp_mapscr->cset[k]),f))
17062 return qe_invalid;
17063 544192 }
17064 3092 }
17065
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 if(scr_has_flags & SCRHAS_MISC)
17066 {
17067
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 if(!p_igetw(&(temp_mapscr->color),f))
17068 return qe_invalid;
17069
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 if(!p_getc(&(temp_mapscr->csensitive),f))
17070 return qe_invalid;
17071
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 if(!p_getc(&(temp_mapscr->oceansfx),f))
17072 return qe_invalid;
17073
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 if(!p_getc(&(temp_mapscr->bosssfx),f))
17074 return qe_invalid;
17075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6037 times.
6037 if(!p_getc(&(temp_mapscr->secretsfx),f))
17076 return qe_invalid;
17077
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 if(!p_getc(&(temp_mapscr->holdupsfx),f))
17078 return qe_invalid;
17079
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
17080 return qe_invalid;
17081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6037 times.
6037 if(!p_igetw(&(temp_mapscr->screen_midi),f))
17082 return qe_invalid;
17083
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 if(!p_getc(&(temp_mapscr->lens_layer),f))
17084 return qe_invalid;
17085
2/2
✓ Branch 0 taken 5301 times.
✓ Branch 1 taken 736 times.
6037 if(version > 27)
17086 {
17087
1/2
✓ Branch 0 taken 736 times.
✗ Branch 1 not taken.
736 if(!p_getc(&(temp_mapscr->lens_show),f))
17088 return qe_invalid;
17089
1/2
✓ Branch 0 taken 736 times.
✗ Branch 1 not taken.
736 if(!p_getc(&(temp_mapscr->lens_hide),f))
17090 return qe_invalid;
17091 736 }
17092 6037 }
17093 else
17094 {
17095 temp_mapscr->screen_midi = -1;
17096 temp_mapscr->csensitive = 1;
17097 }
17098 //FFC
17099 6037 bool old_ff = version < 25;
17100 6037 dword bits = 0;
17101 6037 word numffc = 32;
17102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6037 times.
6037 if(old_ff)
17103 {
17104 if(!p_igetl(&bits,f))
17105 return qe_invalid;
17106 }
17107 else
17108 {
17109
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 if(!p_igetw(&numffc,f))
17110 return qe_invalid;
17111 }
17112 byte tempbyte;
17113 word tempw;
17114
4/6
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 6005 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 32 times.
6037 static ffcdata nil_ffc;
17115 6037 temp_mapscr->ffcCountMarkDirty();
17116
2/2
✓ Branch 0 taken 6037 times.
✓ Branch 1 taken 8259 times.
14296 for(word m = 0; m < numffc; ++m)
17117 {
17118
1/2
✓ Branch 0 taken 8259 times.
✗ Branch 1 not taken.
8259 ffcdata& tempffc = (m < MAXFFCS)
17119 8259 ? temp_mapscr->ffcs[m]
17120 : nil_ffc; //sanity
17121 8259 tempffc.clear();
17122
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8259 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8259 if(old_ff && !(bits & (1<<m))) continue;
17123
17124
1/2
✓ Branch 0 taken 8259 times.
✗ Branch 1 not taken.
8259 if(!p_igetw(&tempw,f))
17125 return qe_invalid;
17126
3/4
✓ Branch 0 taken 8259 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1517 times.
✓ Branch 3 taken 6742 times.
8259 if(!old_ff && !tempw) //empty ffc, nothing more to load
17127 6742 continue;
17128 1517 tempffc.setData(tempw);
17129
17130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1517 times.
1517 if(!p_getc(&(tempffc.cset),f))
17131 return qe_invalid;
17132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1517 times.
1517 if(!p_igetw(&(tempffc.delay),f))
17133 return qe_invalid;
17134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1517 times.
1517 if(!p_igetzf(&(tempffc.x),f))
17135 return qe_invalid;
17136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1517 times.
1517 if(!p_igetzf(&(tempffc.y),f))
17137 return qe_invalid;
17138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1517 times.
1517 if(!p_igetzf(&(tempffc.vx),f))
17139 return qe_invalid;
17140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1517 times.
1517 if(!p_igetzf(&(tempffc.vy),f))
17141 return qe_invalid;
17142
1/2
✓ Branch 0 taken 1517 times.
✗ Branch 1 not taken.
1517 if(!p_igetzf(&(tempffc.ax),f))
17143 return qe_invalid;
17144
1/2
✓ Branch 0 taken 1517 times.
✗ Branch 1 not taken.
1517 if(!p_igetzf(&(tempffc.ay),f))
17145 return qe_invalid;
17146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1517 times.
1517 if(!p_getc(&(tempffc.link),f))
17147 return qe_invalid;
17148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1517 times.
1517 if(version < 24)
17149 {
17150 if(!p_getc(&tempbyte,f))
17151 return qe_invalid;
17152 tempffc.hit_width = (tempbyte&0x3F)+1;
17153 tempffc.txsz = (tempbyte>>6)+1;
17154 if(!p_getc(&tempbyte,f))
17155 return qe_invalid;
17156 tempffc.hit_height = (tempbyte&0x3F)+1;
17157 tempffc.tysz = (tempbyte>>6)+1;
17158 }
17159 else
17160 {
17161
1/2
✓ Branch 0 taken 1517 times.
✗ Branch 1 not taken.
1517 if(!p_igetl(&(tempffc.hit_width),f))
17162 return qe_invalid;
17163
1/2
✓ Branch 0 taken 1517 times.
✗ Branch 1 not taken.
1517 if(!p_igetl(&(tempffc.hit_height),f))
17164 return qe_invalid;
17165
1/2
✓ Branch 0 taken 1517 times.
✗ Branch 1 not taken.
1517 if(!p_getc(&(tempffc.txsz),f))
17166 return qe_invalid;
17167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1517 times.
1517 if(!p_getc(&(tempffc.tysz),f))
17168 return qe_invalid;
17169 }
17170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1517 times.
1517 if(!p_igetl(&(tempffc.flags),f))
17171 return qe_invalid;
17172 1517 tempffc.updateSolid();
17173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1517 times.
1517 if(!p_igetw(&(tempffc.script),f))
17174 return qe_invalid;
17175
2/2
✓ Branch 0 taken 12136 times.
✓ Branch 1 taken 1517 times.
13653 for(auto q = 0; q < 8; ++q)
17176 {
17177
1/2
✓ Branch 0 taken 12136 times.
✗ Branch 1 not taken.
12136 if(!p_igetl(&(tempffc.initd[q]),f))
17178 return qe_invalid;
17179 12136 }
17180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1517 times.
1517 if(!p_getc(&(tempbyte),f))
17181 return qe_invalid;
17182 1517 tempffc.inita[0]=tempbyte*10000;
17183
17184
1/2
✓ Branch 0 taken 1517 times.
✗ Branch 1 not taken.
1517 if(!p_getc(&(tempbyte),f))
17185 return qe_invalid;
17186 1517 tempffc.inita[1]=tempbyte*10000;
17187
17188
1/2
✓ Branch 0 taken 1517 times.
✗ Branch 1 not taken.
1517 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17189 {
17190 tempffc.script = 0;
17191 for(int q = 0; q < 8; ++q)
17192 tempffc.initd[q] = 0;
17193 }
17194 1517 }
17195
2/2
✓ Branch 0 taken 764477 times.
✓ Branch 1 taken 6037 times.
770514 for(word m = numffc; m < MAXFFCS; ++m)
17196 {
17197 764477 temp_mapscr->ffcs[m].clear();
17198 764477 }
17199 //END FFC
17200 }
17201 253213 return 0;
17202 263360 }
17203
17204
17205 128 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17206 {
17207
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
17208 128 int32_t scr=0;
17209
17210 128 word version=0;
17211 dword dummy;
17212 int32_t screens_to_read;
17213
17214 128 mapscr temp_mapscr;
17215 word temp_map_count;
17216 dword section_size;
17217
17218
3/6
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17219 {
17220 4 screens_to_read=MAPSCRS192b136;
17221 4 }
17222 else
17223 {
17224 124 screens_to_read=MAPSCRS;
17225 }
17226
17227
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if(Header->zelda_version > 0x192)
17228 {
17229 //section version info
17230
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&version,f))
17231 {
17232 return qe_invalid;
17233 }
17234
17235 124 FFCore.quest_format[vMaps] = version;
17236
17237 //al_trace("Maps version %d\n", version);
17238
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&dummy,f))
17239 {
17240 return qe_invalid;
17241 }
17242
17243 //section size
17244
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&section_size,f))
17245 {
17246 return qe_invalid;
17247 }
17248
17249 //finally... section data
17250
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&temp_map_count,f))
17251 {
17252 return 5;
17253 }
17254 124 }
17255 else
17256 {
17257 4 temp_map_count=map_count;
17258 }
17259
17260
2/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
128 if (!(temp_map_count >= 0 && temp_map_count <= MAXMAPS))
17261 {
17262 return qe_invalid;
17263 }
17264
17265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (!should_skip)
17266 {
17267 128 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17268 128 TheMaps.resize(_mapsSize);
17269 128 map_autolayers.clear();
17270 128 map_autolayers.resize(temp_map_count*6);
17271
2/2
✓ Branch 0 taken 264520 times.
✓ Branch 1 taken 128 times.
264648 for(int32_t i(0); i<_mapsSize; i++)
17272 264520 TheMaps[i].zero_memory();
17273 128 }
17274
17275 128 temp_mapscr.zero_memory();
17276
17277
4/4
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 1945 times.
✓ Branch 2 taken 1945 times.
✓ Branch 3 taken 128 times.
2073 for(int32_t i=0; i<temp_map_count && i<MAXMAPS; i++)
17278 {
17279 1945 byte valid=1;
17280
2/2
✓ Branch 0 taken 1819 times.
✓ Branch 1 taken 126 times.
1945 if(version > 22)
17281 {
17282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(!p_getc(&valid,f))
17283 return qe_invalid;
17284 126 }
17285
4/4
✓ Branch 0 taken 1938 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 1886 times.
✓ Branch 3 taken 52 times.
1945 if(valid && version > 25)
17286 {
17287
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 52 times.
364 for(int q = 0; q < 6; ++q)
17288 {
17289
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(!p_igetw(&map_autolayers[i*6+q],f))
17290 return qe_invalid;
17291 312 }
17292 52 }
17293
2/2
✓ Branch 0 taken 264312 times.
✓ Branch 1 taken 1945 times.
266257 for(int32_t j=0; j<screens_to_read; j++)
17294 {
17295 264312 scr=i*MAPSCRS+j;
17296 264312 clear_screen(&temp_mapscr);
17297
2/2
✓ Branch 0 taken 952 times.
✓ Branch 1 taken 263360 times.
264312 if(valid)
17298 263360 readmapscreen(f, Header, &temp_mapscr, version, scr);
17299
17300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264312 times.
264312 if (!should_skip)
17301 264312 TheMaps[scr] = temp_mapscr;
17302 264312 }
17303
17304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1945 times.
1945 if (should_skip)
17305 continue;
17306
17307
3/6
✓ Branch 0 taken 1893 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1893 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1945 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17308 {
17309 52 int32_t index = (i*MAPSCRS+132);
17310
17311 52 TheMaps[index]=TheMaps[index-1];
17312
17313 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17314 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17315 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17316
17317
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 52 times.
208 for(int32_t j=133; j<MAPSCRS; j++)
17318 {
17319 156 scr=i*MAPSCRS+j;
17320
17321 156 TheMaps[scr].zero_memory();
17322 156 TheMaps[scr].valid = mVERSION;
17323 156 TheMaps[scr].screen_midi = -1;
17324 156 TheMaps[scr].csensitive = 1;
17325 156 }
17326 52 }
17327
17328
3/6
✓ Branch 0 taken 1893 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1893 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1945 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17329 {
17330
2/2
✓ Branch 0 taken 7072 times.
✓ Branch 1 taken 52 times.
7124 for(int32_t j=0; j<MAPSCRS; j++)
17331 {
17332 7072 scr=i*MAPSCRS+j;
17333 7072 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17334
17335
2/2
✓ Branch 0 taken 905216 times.
✓ Branch 1 taken 7072 times.
912288 for(int32_t k=0; k<128; k++)
17336 {
17337 905216 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17338 905216 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17339 905216 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17340 905216 }
17341 7072 }
17342 52 }
17343 1945 }
17344 128 map_count = temp_map_count;
17345 128 clear_screen(&temp_mapscr);
17346 128 return 0;
17347 128 }
17348
17349
17350 1089313 void update_combo(newcombo& cmb, word section_version)
17351 {
17352
2/2
✓ Branch 0 taken 148596 times.
✓ Branch 1 taken 940717 times.
1089313 if(section_version < 40)
17353 {
17354
3/3
✓ Branch 0 taken 1389 times.
✓ Branch 1 taken 14209 times.
✓ Branch 2 taken 925119 times.
940717 switch(cmb.type)
17355 {
17356 case cWATER: case cSHALLOWWATER:
17357 14209 cmb.attribytes[6] = iwRipples;
17358 14209 break;
17359 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17360 1389 cmb.attribytes[6] = iwTallGrass;
17361 1389 break;
17362 }
17363 940717 }
17364 1089313 }
17365 95 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17366 {
17367
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4 times.
95 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
17368
17369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if (!should_skip)
17370 {
17371 95 reset_combo_animations();
17372 95 reset_combo_animations2();
17373 95 init_combo_classes();
17374 95 }
17375
17376 // combos
17377 95 word combos_used=0;
17378 int32_t dummy;
17379 byte padding;
17380 95 newcombo temp_combo;
17381 //word section_cversion=0;
17382
17383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if (!should_skip)
17384
2/2
✓ Branch 0 taken 6201600 times.
✓ Branch 1 taken 95 times.
6201695 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17385
1/2
✓ Branch 0 taken 6201600 times.
✗ Branch 1 not taken.
6201695 combobuf[q].clear();
17386
17387 // if(version > 0x192)
17388 // {
17389 // //section version info
17390 // if(!p_igetw(&section_version,f))
17391 // {
17392 // return qe_invalid;
17393 // }
17394
17395 // FFCore.quest_format[vCombos] = section_version;
17396
17397 // //al_trace("Combos version %d\n", section_version);
17398 // if(!p_igetw(&section_cversion,f))
17399 // {
17400 // return qe_invalid;
17401 // }
17402
17403 // //section size
17404 // if(!p_igetl(&dummy,f))
17405 // {
17406 // return qe_invalid;
17407 // }
17408 // }
17409
17410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if(version < 0x174)
17411 {
17412 combos_used=1024;
17413 }
17414
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4 times.
95 else if(version < 0x191)
17415 {
17416 4 combos_used=2048;
17417 4 }
17418 else
17419 {
17420
2/4
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 91 times.
✗ Branch 3 not taken.
91 if(!p_igetw(&combos_used,f))
17421 {
17422 return qe_invalid;
17423 }
17424 }
17425
17426 //finally... section data
17427
2/2
✓ Branch 0 taken 873209 times.
✓ Branch 1 taken 95 times.
873304 for(int32_t i=0; i<combos_used; i++)
17428 {
17429
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 temp_combo.clear();
17430
17431
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if ( section_version >= 11 )
17432 {
17433
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.tile,f))
17434 {
17435 return qe_invalid;
17436 }
17437 68884 }
17438 else
17439 {
17440
2/4
✓ Branch 0 taken 804325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 804325 times.
✗ Branch 3 not taken.
804325 if(!p_igetw(&temp_combo.tile,f))
17441 {
17442 return qe_invalid;
17443 }
17444 }
17445 873209 temp_combo.o_tile = temp_combo.tile;
17446
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.flip,f))
17447 {
17448 return qe_invalid;
17449 }
17450
17451
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.walk,f))
17452 {
17453 return qe_invalid;
17454 }
17455
17456
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.type,f))
17457 {
17458 return qe_invalid;
17459 }
17460
17461
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.csets,f))
17462 {
17463 return qe_invalid;
17464 }
17465
17466
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 865017 times.
873209 if(version < 0x193)
17467 {
17468
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f))
17469 return qe_invalid;
17470
17471
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f))
17472 return qe_invalid;
17473
17474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8192 times.
8192 if(version < 0x192)
17475 {
17476
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(version == 0x191)
17477 {
17478 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17479 {
17480 if(!p_getc(&padding,f))
17481 return qe_invalid;
17482 }
17483 }
17484 8192 }
17485 8192 }
17486
2/2
✓ Branch 0 taken 865017 times.
✓ Branch 1 taken 8192 times.
873209 if(version >= 0x192)
17487 {
17488
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.frames,f))
17489 return qe_invalid;
17490
17491
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.speed,f))
17492 return qe_invalid;
17493
17494
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_igetw(&temp_combo.nextcombo,f))
17495 return qe_invalid;
17496
17497
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.nextcset,f))
17498 return qe_invalid;
17499
17500 //Base flag
17501
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=3)
17502
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.flag,f))
17503 return qe_invalid;
17504
17505
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=4)
17506 {
17507
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.skipanim,f))
17508 return qe_invalid;
17509
17510
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_igetw(&temp_combo.nexttimer,f))
17511 return qe_invalid;
17512 399183 }
17513
17514
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=5)
17515
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.skipanimy,f))
17516 return qe_invalid;
17517
17518
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=6)
17519 {
17520
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.animflags,f))
17521 return qe_invalid;
17522
17523
1/2
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
399183 if(section_version == 6)
17524 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17525 399183 }
17526
17527
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=8) //combo Attributes[4] and userflags.
17528 {
17529
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 275536 times.
344420 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17530
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_igetl(&temp_combo.attributes[q],f))
17531 return qe_invalid;
17532
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.usrflags,f))
17533 return qe_invalid;
17534
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(section_version >= 20)
17535
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.genflags,f))
17536 return qe_invalid;
17537 68884 }
17538
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=10) //combo trigger flags
17539 {
17540
2/2
✓ Branch 0 taken 206652 times.
✓ Branch 1 taken 68884 times.
275536 for ( int32_t q = 0; q < 3; q++ )
17541
2/4
✓ Branch 0 taken 206652 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 206652 times.
✗ Branch 3 not taken.
206652 if(!p_igetl(&temp_combo.triggerflags[q],f))
17542 return qe_invalid;
17543 68884 }
17544
1/2
✓ Branch 0 taken 796133 times.
✗ Branch 1 not taken.
796133 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17545 {
17546 for ( int32_t q = 0; q < 2; q++ )
17547 if(!p_igetl(&temp_combo.triggerflags[q],f))
17548 return qe_invalid;
17549 }
17550
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version >= 9)
17551
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.triggerlevel,f))
17552 return qe_invalid;
17553
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version >= 22)
17554
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.triggerbtn,f))
17555 return qe_invalid;
17556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 24)
17557 {
17558 if(!p_getc(&temp_combo.triggeritem,f))
17559 return qe_invalid;
17560 if(!p_getc(&temp_combo.trigtimer,f))
17561 return qe_invalid;
17562 }
17563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 25)
17564 if(!p_getc(&temp_combo.trigsfx,f))
17565 return qe_invalid;
17566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 27)
17567 if(!p_igetl(&temp_combo.trigchange,f))
17568 return qe_invalid;
17569
17570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 29)
17571 {
17572 if(!p_igetw(&temp_combo.trigprox,f))
17573 return qe_invalid;
17574 if(!p_getc(&temp_combo.trigctr,f))
17575 return qe_invalid;
17576 if(!p_igetl(&temp_combo.trigctramnt,f))
17577 return qe_invalid;
17578 }
17579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 30)
17580 if(!p_getc(&temp_combo.triglbeam,f))
17581 return qe_invalid;
17582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 31)
17583 {
17584 if(!p_getc(&temp_combo.trigcschange,f))
17585 return qe_invalid;
17586 if(!p_igetw(&temp_combo.spawnitem,f))
17587 return qe_invalid;
17588 if(!p_igetw(&temp_combo.spawnenemy,f))
17589 return qe_invalid;
17590 if(!p_getc(&temp_combo.exstate,f))
17591 return qe_invalid;
17592 if(!p_igetl(&temp_combo.spawnip,f))
17593 return qe_invalid;
17594 if(!p_getc(&temp_combo.trigcopycat,f))
17595 return qe_invalid;
17596 }
17597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 32)
17598 if(!p_getc(&temp_combo.trigcooldown,f))
17599 return qe_invalid;
17600
17601
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=12) //combo label
17602 {
17603 char label[12];
17604 68884 label[11] = '\0';
17605
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 757724 times.
826608 for ( int32_t q = 0; q < 11; q++ )
17606
2/4
✓ Branch 0 taken 757724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757724 times.
✗ Branch 3 not taken.
757724 if(!p_getc(&label[q],f))
17607 return qe_invalid;
17608
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 temp_combo.label = label;
17609 68884 }
17610
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=13) //attribytes[4]
17611
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < 4; q++ )
17612
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f))
17613 68884 return qe_invalid;
17614 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17615 * This fixes a poor implementation of a ->next flag bug thing.
17616 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17617 * there was a version bump a few weeks before a change that broke stuff.
17618 */
17619
3/4
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68884 times.
865017 if (section_version >= 13 && section_version < 21)
17620 {
17621 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17622 }
17623 //combo scripts
17624
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=14)
17625 {
17626
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.script,f))
17627 return qe_invalid;
17628
2/2
✓ Branch 0 taken 137768 times.
✓ Branch 1 taken 68884 times.
206652 for ( int32_t q = 0; q < 2; q++ )
17629
2/4
✓ Branch 0 taken 137768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137768 times.
✗ Branch 3 not taken.
137768 if(!p_igetl(&temp_combo.initd[q],f))
17630 return qe_invalid;
17631 68884 }
17632 //al_trace("Read combo script data\n");
17633
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=15)
17634 {
17635
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17636
2/2
✓ Branch 0 taken 37028 times.
✓ Branch 1 taken 31856 times.
68884 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17637
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
17638
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
17639 68884 }
17640
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=17) //attribytes[4]
17641 {
17642
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17643
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f))
17644 return qe_invalid;
17645
2/2
✓ Branch 0 taken 551072 times.
✓ Branch 1 taken 68884 times.
619956 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17646
2/4
✓ Branch 0 taken 551072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 551072 times.
✗ Branch 3 not taken.
551072 if(!p_igetw(&temp_combo.attrishorts[q],f))
17647 return qe_invalid;
17648 68884 }
17649
17650
1/2
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
865017 if(version < 0x193)
17651 for(int32_t q=0; q<11; q++)
17652 if(!p_getc(&dummy,f))
17653 return qe_invalid;
17654 865017 }
17655
17656 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17657
3/6
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 474026 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 399183 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
873209 if((version < 0x211)||((version == 0x211)&&(build<7)))
17658 {
17659
3/4
✓ Branch 0 taken 474026 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 465834 times.
✓ Branch 3 taken 8192 times.
474026 if(!get_qr(qr_NEWENEMYTILES))
17660 {
17661
1/5
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
8192 switch(temp_combo.tile)
17662 {
17663 case 130:
17664 temp_combo.tile = 132;
17665 break;
17666
17667 case 131:
17668 temp_combo.tile = 133;
17669 break;
17670
17671 case 132:
17672 temp_combo.tile = 130;
17673 break;
17674
17675 case 133:
17676 temp_combo.tile = 131;
17677 break;
17678 }
17679 8192 }
17680 474026 }
17681
17682
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 15)
17683 804325 temp_combo.o_tile = temp_combo.tile;
17684
17685
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version<18) //upper bits for .walk
17686 804325 temp_combo.walk |= 0xF0;
17687
17688
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 19)
17689
2/2
✓ Branch 0 taken 3217300 times.
✓ Branch 1 taken 804325 times.
4021625 for(int32_t q = 0; q < 4; ++q)
17690 4021625 temp_combo.attributes[q] *= 10000L;
17691
17692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 23)
17693 {
17694
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 872825 times.
873209 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17695 {
17696 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17697 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17698 case cTRIGGERGENERIC: case cCSWITCH:
17699 384 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17700 384 }
17701 873209 }
17702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 25)
17703 {
17704
2/2
✓ Branch 0 taken 3061 times.
✓ Branch 1 taken 870148 times.
873209 switch(temp_combo.type)
17705 {
17706 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3061 times.
3061 if(!(temp_combo.usrflags & cflag3))
17708 3061 temp_combo.attribytes[3] = WAV_DOOR;
17709 3061 temp_combo.usrflags &= ~cflag3;
17710 3061 break;
17711 }
17712 873209 }
17713
17714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 26)
17715
2/2
✓ Branch 0 taken 872622 times.
✓ Branch 1 taken 587 times.
873796 if(temp_combo.type == cARMOS)
17716
1/2
✓ Branch 0 taken 587 times.
✗ Branch 1 not taken.
587 if(temp_combo.usrflags & cflag1)
17717 temp_combo.usrflags |= cflag3;
17718
17719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 27)
17720 {
17721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17722 temp_combo.trigchange = 1;
17723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17724 temp_combo.trigchange = -1;
17725 873209 else temp_combo.trigchange = 0;
17726 873209 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17727 873209 }
17728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 28)
17729 {
17730
2/2
✓ Branch 0 taken 1689 times.
✓ Branch 1 taken 871520 times.
873209 switch(temp_combo.type)
17731 {
17732 case cLOCKBLOCK: case cLOCKEDCHEST:
17733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1689 times.
1689 if(temp_combo.usrflags & cflag7)
17734 temp_combo.usrflags |= cflag8;
17735 1689 else temp_combo.usrflags &= ~cflag8;
17736 1689 temp_combo.usrflags &= ~cflag7;
17737 1689 break;
17738 }
17739
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 873140 times.
873209 switch(temp_combo.type)
17740 {
17741 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
17742 69 temp_combo.attrishorts[2] = -1;
17743 69 temp_combo.usrflags |= cflag7;
17744 69 break;
17745 }
17746 873209 }
17747
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 20)
17748 {
17749 804325 temp_combo.genflags = 0;
17750
2/2
✓ Branch 0 taken 19291 times.
✓ Branch 1 taken 785034 times.
804325 switch(temp_combo.type)
17751 {
17752 case cPUSH_WAIT: case cPUSH_HEAVY:
17753 case cPUSH_HW: case cL_STATUE:
17754 case cR_STATUE: case cPUSH_HEAVY2:
17755 case cPUSH_HW2: case cPOUND:
17756 case cC_STATUE: case cMIRROR:
17757 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17758 case cMAGICPRISM: case cMAGICPRISM4:
17759 case cMAGICSPONGE: case cEYEBALL_A:
17760 case cEYEBALL_B: case cEYEBALL_4:
17761 case cBUSH: case cFLOWERS:
17762 case cLOCKBLOCK: case cLOCKBLOCK2:
17763 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17764 case cCHEST: case cCHEST2:
17765 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17766 case cBOSSCHEST: case cBOSSCHEST2:
17767 case cBUSHNEXT: case cBUSHTOUCHY:
17768 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17769 case cSIGNPOST: case cCSWITCHBLOCK:
17770 case cTORCH: case cTRIGGERGENERIC:
17771
1/2
✓ Branch 0 taken 19291 times.
✗ Branch 1 not taken.
19291 if(temp_combo.usrflags & cflag16)
17772 {
17773 temp_combo.genflags |= cflag1;
17774 temp_combo.usrflags &= ~cflag16;
17775 }
17776 19291 break;
17777 }
17778 804325 }
17779
17780 873209 update_combo(temp_combo, section_version);
17781
17782
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(i>=start_combo && !should_skip)
17783 {
17784
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17785 {
17786 temp_combo.script = 0;
17787 for(int q = 0; q < 8; ++q)
17788 temp_combo.initd[q] = 0;
17789 }
17790
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 combobuf[i] = temp_combo;
17791 873209 }
17792 873209 }
17793
17794
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 if (should_skip)
17795 return 0;
17796
17797
3/6
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 91 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
95 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
17798 {
17799
2/2
✓ Branch 0 taken 261120 times.
✓ Branch 1 taken 4 times.
261124 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17800 {
17801
1/2
✓ Branch 0 taken 261120 times.
✗ Branch 1 not taken.
261120 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
17802 {
17803 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
17804 }
17805 261120 }
17806 4 }
17807
17808 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
17809
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 83 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
95 if(version == 0x210 && !is_editor())
17810 {
17811
2/2
✓ Branch 0 taken 783360 times.
✓ Branch 1 taken 12 times.
783372 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17812
2/2
✓ Branch 0 taken 783351 times.
✓ Branch 1 taken 9 times.
783369 if(combobuf[tmpcounter].type == cLADDERONLY)
17813 9 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
17814 12 }
17815
17816
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 16 times.
95 if(section_version<7)
17817 {
17818
2/2
✓ Branch 0 taken 1044480 times.
✓ Branch 1 taken 16 times.
1044496 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17819 {
17820
6/9
✓ Branch 0 taken 1043840 times.
✓ Branch 1 taken 250 times.
✓ Branch 2 taken 174 times.
✓ Branch 3 taken 126 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 45 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
1044480 switch(combobuf[tmpcounter].type)
17821 {
17822 case cSLASH:
17823 250 combobuf[tmpcounter].type=cSLASHTOUCHY;
17824 250 break;
17825
17826 case cSLASHITEM:
17827 174 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
17828 174 break;
17829
17830 case cBUSH:
17831 126 combobuf[tmpcounter].type=cBUSHTOUCHY;
17832 126 break;
17833
17834 case cFLOWERS:
17835 45 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
17836 45 break;
17837
17838 case cTALLGRASS:
17839 45 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
17840 45 break;
17841
17842 case cSLASHNEXT:
17843 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
17844 break;
17845
17846 case cSLASHNEXTITEM:
17847 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
17848 break;
17849
17850 case cBUSHNEXT:
17851 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
17852 break;
17853 }
17854 1044480 }
17855 16 }
17856
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 93 times.
95 if (section_version < 16)
17857 {
17858
2/2
✓ Branch 0 taken 6071040 times.
✓ Branch 1 taken 93 times.
6071133 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17859 {
17860
2/2
✓ Branch 0 taken 6062986 times.
✓ Branch 1 taken 8054 times.
6071040 if (combobuf[tmpcounter].type == cWATER)
17861 {
17862 8054 combobuf[tmpcounter].attributes[0] = 40000L;
17863 8054 }
17864 6071040 }
17865 93 }
17866
3/4
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 1 times.
95 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
17867 {
17868 1 combobuf[0].walk = 0xF0;
17869 1 combobuf[0].type = 0;
17870 1 combobuf[0].flag = 0;
17871 1 }
17872
17873 //Now for the new combo alias reset
17874
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 16 times.
95 if(section_version<2)
17875 {
17876
2/2
✓ Branch 0 taken 131072 times.
✓ Branch 1 taken 16 times.
131088 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
17877 {
17878 131072 combo_aliases[j].width = 0;
17879 131072 combo_aliases[j].height = 0;
17880 131072 combo_aliases[j].layermask = 0;
17881
17882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 if(combo_aliases[j].combos != NULL)
17883 {
17884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 delete[] combo_aliases[j].combos;
17885 131072 }
17886
17887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 if(combo_aliases[j].csets != NULL)
17888 {
17889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 delete[] combo_aliases[j].csets;
17890 131072 }
17891
17892
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 combo_aliases[j].combos = new word[1];
17893
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 combo_aliases[j].csets = new byte[1];
17894 131072 combo_aliases[j].combos[0] = 0;
17895 131072 combo_aliases[j].csets[0] = 0;
17896 131072 }
17897 16 }
17898
17899
17900
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 setup_combo_animations();
17901
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 setup_combo_animations2();
17902 95 return 0;
17903 95 }
17904 216104 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
17905 {
17906 byte combo_has_flags;
17907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216104 times.
216104 if(!p_getc(&combo_has_flags,f))
17908 return qe_invalid;
17909
17910 216104 temp_combo.clear();
17911
2/2
✓ Branch 0 taken 143879 times.
✓ Branch 1 taken 72225 times.
216104 if(combo_has_flags)
17912 {
17913
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 72222 times.
72225 if(combo_has_flags&CHAS_BASIC)
17914 {
17915
1/2
✓ Branch 0 taken 72222 times.
✗ Branch 1 not taken.
72222 if(!p_igetl(&temp_combo.tile,f))
17916 {
17917 return qe_invalid;
17918 }
17919 72222 temp_combo.o_tile = temp_combo.tile;
17920
17921
1/2
✓ Branch 0 taken 72222 times.
✗ Branch 1 not taken.
72222 if(!p_getc(&temp_combo.flip,f))
17922 {
17923 return qe_invalid;
17924 }
17925
17926
1/2
✓ Branch 0 taken 72222 times.
✗ Branch 1 not taken.
72222 if(!p_getc(&temp_combo.walk,f))
17927 {
17928 return qe_invalid;
17929 }
17930
17931
1/2
✓ Branch 0 taken 72222 times.
✗ Branch 1 not taken.
72222 if(!p_getc(&temp_combo.type,f))
17932 {
17933 return qe_invalid;
17934 }
17935
17936
1/2
✓ Branch 0 taken 72222 times.
✗ Branch 1 not taken.
72222 if(!p_getc(&temp_combo.flag,f))
17937 {
17938 return qe_invalid;
17939 }
17940
17941
1/2
✓ Branch 0 taken 72222 times.
✗ Branch 1 not taken.
72222 if(!p_getc(&temp_combo.csets,f))
17942 {
17943 return qe_invalid;
17944 }
17945 72222 }
17946
2/2
✓ Branch 0 taken 72202 times.
✓ Branch 1 taken 23 times.
72225 if(combo_has_flags&CHAS_SCRIPT)
17947 {
17948
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 15 times.
23 if (s_version>=41)
17949 {
17950 8 p_getcstr(&temp_combo.label, f);
17951 8 }
17952 else
17953 {
17954 char label[12];
17955 15 label[11] = '\0';
17956
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 15 times.
180 for ( int32_t q = 0; q < 11; q++ )
17957 {
17958
1/2
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
165 if(!p_getc(&label[q],f))
17959 {
17960 return qe_invalid;
17961 }
17962 165 }
17963 15 temp_combo.label = label;
17964 }
17965
17966
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
17967 23 auto initd_count = s_version >= 43 ? 8 : 2;
17968
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 23 times.
117 for ( int32_t q = 0; q < initd_count; q++ )
17969 {
17970
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if(!p_igetl(&temp_combo.initd[q],f))
17971 {
17972 return qe_invalid;
17973 }
17974 94 }
17975 23 }
17976
2/2
✓ Branch 0 taken 52218 times.
✓ Branch 1 taken 20007 times.
72225 if(combo_has_flags&CHAS_ANIM)
17977 {
17978
1/2
✓ Branch 0 taken 20007 times.
✗ Branch 1 not taken.
20007 if(!p_getc(&temp_combo.frames,f))
17979 {
17980 return qe_invalid;
17981 }
17982
17983
1/2
✓ Branch 0 taken 20007 times.
✗ Branch 1 not taken.
20007 if(!p_getc(&temp_combo.speed,f))
17984 {
17985 return qe_invalid;
17986 }
17987
17988
1/2
✓ Branch 0 taken 20007 times.
✗ Branch 1 not taken.
20007 if(!p_igetw(&temp_combo.nextcombo,f))
17989 {
17990 return qe_invalid;
17991 }
17992
17993
1/2
✓ Branch 0 taken 20007 times.
✗ Branch 1 not taken.
20007 if(!p_getc(&temp_combo.nextcset,f))
17994 {
17995 return qe_invalid;
17996 }
17997
17998
1/2
✓ Branch 0 taken 20007 times.
✗ Branch 1 not taken.
20007 if(!p_getc(&temp_combo.skipanim,f))
17999 {
18000 return qe_invalid;
18001 }
18002
18003
1/2
✓ Branch 0 taken 20007 times.
✗ Branch 1 not taken.
20007 if(!p_getc(&temp_combo.skipanimy,f))
18004 {
18005 return qe_invalid;
18006 }
18007
18008
1/2
✓ Branch 0 taken 20007 times.
✗ Branch 1 not taken.
20007 if(!p_getc(&temp_combo.animflags,f))
18009 {
18010 return qe_invalid;
18011 }
18012 20007 }
18013
2/2
✓ Branch 0 taken 63735 times.
✓ Branch 1 taken 8490 times.
72225 if(combo_has_flags&CHAS_ATTRIB)
18014 {
18015
2/2
✓ Branch 0 taken 33960 times.
✓ Branch 1 taken 8490 times.
42450 for ( int32_t q = 0; q < 4; q++ )
18016 {
18017
1/2
✓ Branch 0 taken 33960 times.
✗ Branch 1 not taken.
33960 if(!p_igetl(&temp_combo.attributes[q],f))
18018 {
18019 return qe_invalid;
18020 }
18021 33960 }
18022
2/2
✓ Branch 0 taken 67920 times.
✓ Branch 1 taken 8490 times.
76410 for ( int32_t q = 0; q < 8; q++ )
18023 {
18024
1/2
✓ Branch 0 taken 67920 times.
✗ Branch 1 not taken.
67920 if(!p_getc(&temp_combo.attribytes[q],f))
18025 {
18026 return qe_invalid;
18027 }
18028 67920 }
18029
2/2
✓ Branch 0 taken 67920 times.
✓ Branch 1 taken 8490 times.
76410 for ( int32_t q = 0; q < 8; q++ )
18030 {
18031
1/2
✓ Branch 0 taken 67920 times.
✗ Branch 1 not taken.
67920 if(!p_igetw(&temp_combo.attrishorts[q],f))
18032 {
18033 return qe_invalid;
18034 }
18035 67920 }
18036 8490 }
18037
2/2
✓ Branch 0 taken 70105 times.
✓ Branch 1 taken 2120 times.
72225 if(combo_has_flags&CHAS_FLAG)
18038 {
18039
1/2
✓ Branch 0 taken 2120 times.
✗ Branch 1 not taken.
2120 if(!p_igetl(&temp_combo.usrflags,f))
18040 {
18041 return qe_invalid;
18042 }
18043
1/2
✓ Branch 0 taken 2120 times.
✗ Branch 1 not taken.
2120 if(!p_igetw(&temp_combo.genflags,f))
18044 {
18045 return qe_invalid;
18046 }
18047 2120 }
18048
2/2
✓ Branch 0 taken 71471 times.
✓ Branch 1 taken 754 times.
72225 if(combo_has_flags&CHAS_TRIG)
18049 {
18050 754 int numtrigs = s_version < 36 ? 3 : 6;
18051
2/2
✓ Branch 0 taken 4095 times.
✓ Branch 1 taken 754 times.
4849 for ( int32_t q = 0; q < numtrigs; q++ )
18052 {
18053
1/2
✓ Branch 0 taken 4095 times.
✗ Branch 1 not taken.
4095 if(!p_igetl(&temp_combo.triggerflags[q],f))
18054 {
18055 return qe_invalid;
18056 }
18057 4095 }
18058
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetl(&temp_combo.triggerlevel,f))
18059 {
18060 return qe_invalid;
18061 }
18062
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.triggerbtn,f))
18063 {
18064 return qe_invalid;
18065 }
18066
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.triggeritem,f))
18067 {
18068 return qe_invalid;
18069 }
18070
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.trigtimer,f))
18071 {
18072 return qe_invalid;
18073 }
18074
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.trigsfx,f))
18075 {
18076 return qe_invalid;
18077 }
18078
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetl(&temp_combo.trigchange,f))
18079 {
18080 return qe_invalid;
18081 }
18082
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetw(&temp_combo.trigprox,f))
18083 {
18084 return qe_invalid;
18085 }
18086
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.trigctr,f))
18087 {
18088 return qe_invalid;
18089 }
18090
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetl(&temp_combo.trigctramnt,f))
18091 {
18092 return qe_invalid;
18093 }
18094
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.triglbeam,f))
18095 {
18096 return qe_invalid;
18097 }
18098
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.trigcschange,f))
18099 {
18100 return qe_invalid;
18101 }
18102
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetw(&temp_combo.spawnitem,f))
18103 {
18104 return qe_invalid;
18105 }
18106
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetw(&temp_combo.spawnenemy,f))
18107 {
18108 return qe_invalid;
18109 }
18110
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.exstate,f))
18111 {
18112 return qe_invalid;
18113 }
18114
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetl(&temp_combo.spawnip,f))
18115 {
18116 return qe_invalid;
18117 }
18118
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.trigcopycat,f))
18119 {
18120 return qe_invalid;
18121 }
18122
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.trigcooldown,f))
18123 {
18124 return qe_invalid;
18125 }
18126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 754 times.
754 if(s_version >= 35)
18127 {
18128
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetw(&temp_combo.prompt_cid,f))
18129 {
18130 return qe_invalid;
18131 }
18132
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.prompt_cs,f))
18133 {
18134 return qe_invalid;
18135 }
18136
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetw(&temp_combo.prompt_x,f))
18137 {
18138 return qe_invalid;
18139 }
18140
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetw(&temp_combo.prompt_y,f))
18141 {
18142 return qe_invalid;
18143 }
18144 754 }
18145
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 611 times.
754 if(s_version >= 36)
18146 {
18147
1/2
✓ Branch 0 taken 611 times.
✗ Branch 1 not taken.
611 if(!p_getc(&temp_combo.trig_lstate,f))
18148 {
18149 return qe_invalid;
18150 }
18151
1/2
✓ Branch 0 taken 611 times.
✗ Branch 1 not taken.
611 if(!p_getc(&temp_combo.trig_gstate,f))
18152 {
18153 return qe_invalid;
18154 }
18155
1/2
✓ Branch 0 taken 611 times.
✗ Branch 1 not taken.
611 if(!p_igetl(&temp_combo.trig_statetime,f))
18156 {
18157 return qe_invalid;
18158 }
18159 611 }
18160
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 611 times.
754 if(s_version >= 37)
18161 {
18162
1/2
✓ Branch 0 taken 611 times.
✗ Branch 1 not taken.
611 if(!p_igetw(&temp_combo.trig_genscr,f))
18163 {
18164 return qe_invalid;
18165 }
18166 611 }
18167
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 537 times.
754 if(s_version >= 38)
18168 {
18169
1/2
✓ Branch 0 taken 537 times.
✗ Branch 1 not taken.
537 if(!p_getc(&temp_combo.trig_group,f))
18170 {
18171 return qe_invalid;
18172 }
18173
1/2
✓ Branch 0 taken 537 times.
✗ Branch 1 not taken.
537 if(!p_igetw(&temp_combo.trig_group_val,f))
18174 {
18175 return qe_invalid;
18176 }
18177 537 }
18178 754 }
18179
2/2
✓ Branch 0 taken 72086 times.
✓ Branch 1 taken 139 times.
72225 if(combo_has_flags&CHAS_LIFT)
18180 {
18181
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_igetw(&temp_combo.liftcmb,f))
18182 return qe_invalid;
18183
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&temp_combo.liftcs,f))
18184 return qe_invalid;
18185
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_igetw(&temp_combo.liftundercmb,f))
18186 return qe_invalid;
18187
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&temp_combo.liftundercs,f))
18188 return qe_invalid;
18189
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&temp_combo.liftdmg,f))
18190 return qe_invalid;
18191
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&temp_combo.liftlvl,f))
18192 return qe_invalid;
18193
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&temp_combo.liftitm,f))
18194 return qe_invalid;
18195
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&temp_combo.liftflags,f))
18196 return qe_invalid;
18197
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&temp_combo.liftgfx,f))
18198 return qe_invalid;
18199
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&temp_combo.liftsprite,f))
18200 return qe_invalid;
18201
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&temp_combo.liftsfx,f))
18202 return qe_invalid;
18203
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_igetw(&temp_combo.liftbreaksprite,f))
18204 return qe_invalid;
18205
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&temp_combo.liftbreaksfx,f))
18206 return qe_invalid;
18207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if(s_version >= 34)
18208 {
18209
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&temp_combo.lifthei,f))
18210 return qe_invalid;
18211
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&temp_combo.lifttime,f))
18212 return qe_invalid;
18213 139 }
18214
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 132 times.
139 if(s_version >= 39)
18215 {
18216
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!p_getc(&temp_combo.lift_parent_item,f))
18217 return qe_invalid;
18218 132 }
18219 139 }
18220
2/2
✓ Branch 0 taken 72137 times.
✓ Branch 1 taken 88 times.
72225 if(combo_has_flags&CHAS_GENERAL)
18221 {
18222
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&temp_combo.speed_mult,f))
18223 return qe_invalid;
18224
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&temp_combo.speed_div,f))
18225 return qe_invalid;
18226
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetzf(&temp_combo.speed_add,f))
18227 return qe_invalid;
18228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(s_version >= 42)
18229 {
18230
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&temp_combo.sfx_appear,f))
18231 return qe_invalid;
18232
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&temp_combo.sfx_disappear,f))
18233 return qe_invalid;
18234
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&temp_combo.sfx_loop,f))
18235 return qe_invalid;
18236
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&temp_combo.sfx_walking,f))
18237 return qe_invalid;
18238
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&temp_combo.sfx_standing,f))
18239 return qe_invalid;
18240
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&temp_combo.spr_appear,f))
18241 return qe_invalid;
18242
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&temp_combo.spr_disappear,f))
18243 return qe_invalid;
18244
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&temp_combo.spr_walking,f))
18245 return qe_invalid;
18246
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&temp_combo.spr_standing,f))
18247 return qe_invalid;
18248 88 }
18249 88 }
18250 72225 }
18251 216104 update_combo(temp_combo, s_version);
18252 216104 return 0;
18253 216104 }
18254 128 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
18255 {
18256
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
18257
18258 128 word section_version=0;
18259 128 word section_cversion=0;
18260 128 word combos_used=0;
18261 int32_t dummy;
18262 byte padding;
18263 128 newcombo temp_combo;
18264
18265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (!should_skip)
18266 {
18267
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 reset_combo_animations();
18268
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 reset_combo_animations2();
18269
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 init_combo_classes();
18270
18271
2/2
✓ Branch 0 taken 8355840 times.
✓ Branch 1 taken 128 times.
8355968 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18272
1/2
✓ Branch 0 taken 8355840 times.
✗ Branch 1 not taken.
8355840 combobuf[q].clear();
18273 128 }
18274
18275
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if(version > 0x192) //Version info
18276 {
18277
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetw(&section_version,f))
18278 {
18279 return qe_invalid;
18280 }
18281 124 FFCore.quest_format[vCombos] = section_version;
18282
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetw(&section_cversion,f))
18283 {
18284 return qe_invalid;
18285 }
18286
18287 //section size
18288
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetl(&dummy,f))
18289 {
18290 return qe_invalid;
18291 }
18292 124 }
18293
18294
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 95 times.
128 if(section_version > 32) //Cleanup time!
18295 {
18296
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
33 if(!p_igetw(&combos_used,f))
18297 {
18298 return qe_invalid;
18299 }
18300
2/2
✓ Branch 0 taken 216104 times.
✓ Branch 1 taken 33 times.
216137 for(int32_t i=0; i<combos_used; i++)
18301 {
18302
1/2
✓ Branch 0 taken 216104 times.
✗ Branch 1 not taken.
216104 auto ret = readcombo_loop(f,section_version,temp_combo);
18303
1/2
✓ Branch 0 taken 216104 times.
✗ Branch 1 not taken.
216104 if(ret) return ret;
18304
1/2
✓ Branch 0 taken 216104 times.
✗ Branch 1 not taken.
216104 if(i>=start_combo)
18305 {
18306
1/2
✓ Branch 0 taken 216104 times.
✗ Branch 1 not taken.
216104 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18307 {
18308 temp_combo.script = 0;
18309 for(int q = 0; q < 8; ++q)
18310 temp_combo.initd[q] = 0;
18311 }
18312
1/2
✓ Branch 0 taken 216104 times.
✗ Branch 1 not taken.
216104 combobuf[i] = temp_combo;
18313 216104 }
18314 216104 }
18315 33 }
18316 else //Call the old function for all old versions
18317 {
18318
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if(ret) return ret; //error, end read
18320 }
18321
18322
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if (should_skip)
18323 return 0;
18324
18325
3/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 32 times.
128 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18326 {
18327 32 combobuf[0].walk = 0xF0;
18328 32 combobuf[0].type = 0;
18329 32 combobuf[0].flag = 0;
18330 32 }
18331
18332
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 setup_combo_animations();
18333
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 setup_combo_animations2();
18334 128 return 0;
18335 128 }
18336
18337 112 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18338 {
18339 //these are here to bypass compiler warnings about unused arguments
18340 112 Header=Header;
18341 112 version=version;
18342 112 build=build;
18343
18344 int32_t dummy;
18345 112 word sversion=0, c_sversion;
18346
18347 //section version info
18348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(!p_igetw(&sversion,f))
18349 {
18350 return qe_invalid;
18351 }
18352
18353 112 FFCore.quest_format[vComboAliases] = sversion;
18354
18355 //al_trace("Combo aliases version %d\n", sversion);
18356
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetw(&c_sversion,f))
18357 {
18358 return qe_invalid;
18359 }
18360
18361 //section size
18362
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetl(&dummy,f))
18363 {
18364 return qe_invalid;
18365 }
18366
18367 112 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18368
18369
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 77 times.
112 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18370 {
18371 77 max_num_combo_aliases = MAX250COMBOALIASES;
18372 77 }
18373
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18374 {
18375 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18376 }
18377
18378
2/2
✓ Branch 0 taken 444416 times.
✓ Branch 1 taken 112 times.
444528 for(int32_t j=0; j<max_num_combo_aliases; j++)
18379 {
18380 byte width,height,mask,tempcset;
18381 int32_t count;
18382 word tempword;
18383 byte tempbyte;
18384
18385
1/2
✓ Branch 0 taken 444416 times.
✗ Branch 1 not taken.
444416 if(!p_igetw(&tempword,f))
18386 {
18387 return qe_invalid;
18388 }
18389
18390 444416 combo_aliases[j].combo = tempword;
18391
18392
1/2
✓ Branch 0 taken 444416 times.
✗ Branch 1 not taken.
444416 if(!p_getc(&tempbyte,f))
18393 {
18394 return qe_invalid;
18395 }
18396
18397 444416 combo_aliases[j].cset = tempbyte;
18398
18399
1/2
✓ Branch 0 taken 444416 times.
✗ Branch 1 not taken.
444416 if(!p_getc(&width,f))
18400 {
18401 return qe_invalid;
18402 }
18403
18404
1/2
✓ Branch 0 taken 444416 times.
✗ Branch 1 not taken.
444416 if(!p_getc(&height,f))
18405 {
18406 return qe_invalid;
18407 }
18408
18409
1/2
✓ Branch 0 taken 444416 times.
✗ Branch 1 not taken.
444416 if(!p_getc(&mask,f))
18410 {
18411 return qe_invalid;
18412 }
18413
18414 444416 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18415
18416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 444416 times.
444416 if(combo_aliases[j].combos != NULL)
18417 {
18418
1/2
✓ Branch 0 taken 444416 times.
✗ Branch 1 not taken.
444416 delete[] combo_aliases[j].combos;
18419 444416 }
18420
18421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 444416 times.
444416 if(combo_aliases[j].csets != NULL)
18422 {
18423
1/2
✓ Branch 0 taken 444416 times.
✗ Branch 1 not taken.
444416 delete[] combo_aliases[j].csets;
18424 444416 }
18425
18426 444416 combo_aliases[j].width = width;
18427 444416 combo_aliases[j].height = height;
18428 444416 combo_aliases[j].layermask = mask;
18429 444416 combo_aliases[j].combos = new word[count];
18430 444416 combo_aliases[j].csets = new byte[count];
18431
18432
2/2
✓ Branch 0 taken 455381 times.
✓ Branch 1 taken 444416 times.
899797 for(int32_t k=0; k<count; k++)
18433 {
18434
1/2
✓ Branch 0 taken 455381 times.
✗ Branch 1 not taken.
455381 if(!p_igetw(&tempword,f))
18435 {
18436 return qe_invalid;
18437 }
18438
18439 455381 combo_aliases[j].combos[k] = tempword;
18440 455381 }
18441
18442
2/2
✓ Branch 0 taken 455381 times.
✓ Branch 1 taken 444416 times.
899797 for(int32_t k=0; k<count; k++)
18443 {
18444
1/2
✓ Branch 0 taken 455381 times.
✗ Branch 1 not taken.
455381 if(!p_getc(&tempcset,f))
18445 {
18446 return qe_invalid;
18447 }
18448
18449 455381 combo_aliases[j].csets[k] = tempcset;
18450 455381 }
18451 444416 }
18452
18453 //Combo pools!
18454 112 word num_combo_pools = 0;
18455
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 33 times.
112 if(sversion >= 4)
18456 {
18457
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_igetw(&num_combo_pools,f))
18458 {
18459 return qe_invalid;
18460 }
18461 33 }
18462
18463
2/2
✓ Branch 0 taken 917504 times.
✓ Branch 1 taken 112 times.
917616 for(combo_pool& pool : combo_pools)
18464 {
18465 917504 pool.clear();
18466 }
18467
18468 112 combo_pool temp_cpool;
18469
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 112 times.
202 for(word cp = 0; cp < num_combo_pools; ++cp)
18470 {
18471 90 int32_t num_combos_in_pool = 0;
18472
2/4
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
90 if(!p_igetl(&num_combos_in_pool,f))
18473 {
18474 return qe_invalid;
18475 }
18476
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(num_combos_in_pool < 1) continue; //nothing to read
18477
18478
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 temp_cpool.clear();
18479
18480 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18481
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 390 times.
480 for(auto q = 0; q < num_combos_in_pool; ++q)
18482 {
18483
2/4
✓ Branch 0 taken 390 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 390 times.
✗ Branch 3 not taken.
390 if(!p_igetl(&cp_cid,f))
18484 {
18485 return qe_invalid;
18486 }
18487
2/4
✓ Branch 0 taken 390 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 390 times.
✗ Branch 3 not taken.
390 if(!p_getc(&cp_cs,f))
18488 {
18489 return qe_invalid;
18490 }
18491
2/4
✓ Branch 0 taken 390 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 390 times.
✗ Branch 3 not taken.
390 if(!p_igetw(&cp_quant,f))
18492 {
18493 return qe_invalid;
18494 }
18495
1/2
✓ Branch 0 taken 390 times.
✗ Branch 1 not taken.
390 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18496 390 }
18497
18498
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 combo_pools[cp] = temp_cpool;
18499 90 }
18500
18501 //Autocombos!
18502 112 word num_combo_autos = 0;
18503
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 104 times.
112 if (sversion >= 5)
18504 {
18505
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if (!p_igetw(&num_combo_autos, f))
18506 {
18507 return qe_invalid;
18508 }
18509 8 }
18510
18511
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 917504 times.
917616 for (combo_auto& cauto : combo_autos)
18512 {
18513
1/2
✓ Branch 0 taken 917504 times.
✗ Branch 1 not taken.
917504 cauto.clear(true);
18514 }
18515
18516
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 combo_auto temp_cauto;
18517
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 112 times.
128 for (word ca = 0; ca < num_combo_autos; ++ca)
18518 {
18519 byte type;
18520 int32_t display_cid, erase_cid;
18521 byte flags, arg;
18522
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 if (!p_getc(&type, f))
18523 {
18524 return qe_invalid;
18525 }
18526
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 if (!p_igetl(&display_cid, f))
18527 {
18528 return qe_invalid;
18529 }
18530
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 if (!p_igetl(&erase_cid, f))
18531 {
18532 return qe_invalid;
18533 }
18534
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 if (!p_getc(&flags, f))
18535 {
18536 return qe_invalid;
18537 }
18538
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 if (!p_getc(&arg, f))
18539 {
18540 return qe_invalid;
18541 }
18542 16 int32_t num_combos_in_cauto = 0;
18543
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 if (!p_igetl(&num_combos_in_cauto, f))
18544 {
18545 return qe_invalid;
18546 }
18547
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if (num_combos_in_cauto < 1) continue; //nothing to read
18548
18549
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 temp_cauto.clear();
18550
18551
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 temp_cauto.setType(type);
18552
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 temp_cauto.setDisplay(display_cid);
18553
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 temp_cauto.setEraseCombo(erase_cid);
18554
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 temp_cauto.setFlags(flags);
18555
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 temp_cauto.setArg(arg);
18556
18557 int32_t ca_cid; byte ca_ctype; int16_t ca_offset; int16_t ca_engrave_offset;
18558
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 176 times.
192 for (auto q = 0; q < num_combos_in_cauto; ++q)
18559 {
18560
2/4
✓ Branch 0 taken 176 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
176 if (!p_getc(&ca_ctype, f))
18561 {
18562 return qe_invalid;
18563 }
18564
2/4
✓ Branch 0 taken 176 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
176 if (!p_igetl(&ca_cid, f))
18565 {
18566 return qe_invalid;
18567 }
18568
1/2
✓ Branch 0 taken 176 times.
✗ Branch 1 not taken.
176 temp_cauto.addEntry(ca_cid, ca_ctype, q, -1);
18569 176 }
18570
18571
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 combo_autos[ca] = temp_cauto;
18572 16 }
18573
18574 112 return 0;
18575 112 }
18576
18577 128 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
18578 {
18579
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_colors);
18580
18581 //these are here to bypass compiler warnings about unused arguments
18582 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18583 //Capitalized cause it'll save you a headache. -Deedee
18584 128 start_cset=start_cset;
18585 128 max_csets=max_csets;
18586 128 word s_version=0;
18587
18588 miscQdata temp_misc;
18589 128 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18590
18591 byte temp_colordata[48];
18592 char temp_palname[PALNAMESIZE];
18593
18594 int32_t dummy;
18595 word palcycles;
18596
18597
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(version > 0x192)
18598 {
18599 //section version info
18600
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&s_version,f))
18601 {
18602 return qe_invalid;
18603 }
18604
18605 124 FFCore.quest_format[vCSets] = s_version;
18606
18607 //al_trace("Color data version %d\n", s_version);
18608
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&dummy,f))
18609 {
18610 return qe_invalid;
18611 }
18612
18613 //section size
18614
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&dummy,f))
18615 {
18616 return qe_invalid;
18617 }
18618 124 }
18619
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 35 times.
128 if (s_version < 5)
18620 {
18621
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 89 times.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
93 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18622
18623 //finally... section data
18624 93 int32_t q = 0;
18625 93 int32_t p = -15;
18626
2/2
✓ Branch 0 taken 22320 times.
✓ Branch 1 taken 93 times.
22413 for(int32_t i=0; i<oldpdTOTAL; ++i)
18627 {
18628 22320 memset(temp_colordata, 0, 48);
18629
18630
1/2
✓ Branch 0 taken 22320 times.
✗ Branch 1 not taken.
22320 if(!pfread(temp_colordata,48,f))
18631 {
18632 return qe_invalid;
18633 }
18634
18635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22320 times.
22320 if (should_skip)
18636 continue;
18637
18638 22320 memcpy(&colordata[q*48], temp_colordata, 48);
18639
18640 22320 ++q;
18641
8/8
✓ Branch 0 taken 20832 times.
✓ Branch 1 taken 1488 times.
✓ Branch 2 taken 1581 times.
✓ Branch 3 taken 19251 times.
✓ Branch 4 taken 186 times.
✓ Branch 5 taken 1395 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 178 times.
22320 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18642 {
18643
1/2
✓ Branch 0 taken 1573 times.
✗ Branch 1 not taken.
1573 if (s_version < 5) //Bumping up the size of level palettes
18644 {
18645 1573 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18646 1573 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18647 1573 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18648 1573 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18649 1573 q+=4;
18650 1573 }
18651 else
18652 {
18653 for(int m = 0; m < 4; ++m)
18654 {
18655 memset(temp_colordata, 0, 48);
18656 if(!pfread(temp_colordata,48,f))
18657 {
18658 return qe_invalid;
18659 }
18660 memcpy(&colordata[q*48], temp_colordata, 48);
18661 ++q;
18662 }
18663 }
18664 1573 }
18665 22320 ++p;
18666 22320 }
18667
18668
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 89 times.
93 if(RealOldVerion)
18669 {
18670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!should_skip)
18671 {
18672 4 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18673 4 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18674 4 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18675 4 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18676 4 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18677 4 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18678 4 }
18679 4 }
18680 else
18681 {
18682 89 memset(temp_colordata, 0, 48);
18683
18684
2/2
✓ Branch 0 taken 278837 times.
✓ Branch 1 taken 89 times.
278926 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18685 {
18686
1/2
✓ Branch 0 taken 278837 times.
✗ Branch 1 not taken.
278837 if(!pfread(temp_colordata,48,f))
18687 {
18688 return qe_invalid;
18689 }
18690
18691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278837 times.
278837 if (should_skip)
18692 continue;
18693
18694 278837 memcpy(&colordata[q*48], temp_colordata, 48);
18695
18696 278837 ++q;
18697
7/8
✓ Branch 0 taken 278837 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21449 times.
✓ Branch 3 taken 257388 times.
✓ Branch 4 taken 178 times.
✓ Branch 5 taken 21271 times.
✓ Branch 6 taken 154 times.
✓ Branch 7 taken 24 times.
278837 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18698 {
18699
1/2
✓ Branch 0 taken 21425 times.
✗ Branch 1 not taken.
21425 if (s_version < 5) //Bumping up the size of level palettes
18700 {
18701 21425 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18702 21425 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18703 21425 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18704 21425 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18705 21425 q+=4;
18706 21425 }
18707 else
18708 {
18709 for(int m = 0; m < 4; ++m)
18710 {
18711 memset(temp_colordata, 0, 48);
18712 if(!pfread(temp_colordata,48,f))
18713 {
18714 return qe_invalid;
18715 }
18716 memcpy(&colordata[q*48], temp_colordata, 48);
18717 ++q;
18718 }
18719 }
18720 21425 }
18721 278837 ++p;
18722 278837 }
18723
18724
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 77 times.
89 if(s_version < 4)
18725 {
18726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (!should_skip)
18727 {
18728 12 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18729 12 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18730 12 }
18731 12 }
18732 else
18733 {
18734
2/2
✓ Branch 0 taken 256256 times.
✓ Branch 1 taken 77 times.
256333 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18735 {
18736
1/2
✓ Branch 0 taken 256256 times.
✗ Branch 1 not taken.
256256 if(!pfread(temp_colordata,48,f))
18737 {
18738 return qe_invalid;
18739 }
18740
18741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 256256 times.
256256 if (should_skip)
18742 continue;
18743
18744 256256 memcpy(&colordata[q*48], temp_colordata, 48);
18745 256256 ++q;
18746
5/6
✓ Branch 0 taken 256256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19712 times.
✓ Branch 3 taken 236544 times.
✓ Branch 4 taken 154 times.
✓ Branch 5 taken 19558 times.
256256 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18747 {
18748
1/2
✓ Branch 0 taken 19558 times.
✗ Branch 1 not taken.
19558 if (s_version < 5) //Bumping up the size of level palettes
18749 {
18750 19558 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18751 19558 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18752 19558 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18753 19558 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18754 19558 q+=4;
18755 19558 }
18756 else
18757 {
18758 for(int m = 0; m < 4; ++m)
18759 {
18760 memset(temp_colordata, 0, 48);
18761 if(!pfread(temp_colordata,48,f))
18762 {
18763 return qe_invalid;
18764 }
18765 memcpy(&colordata[q*48], temp_colordata, 48);
18766 ++q;
18767 }
18768 }
18769 19558 }
18770 256256 ++p;
18771 256256 }
18772
18773 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18774 }
18775 }
18776 93 }
18777 else
18778 {
18779
2/2
✓ Branch 0 taken 306215 times.
✓ Branch 1 taken 35 times.
306250 for(int32_t i=0; i<pdTOTAL255; ++i)
18780 {
18781 306215 memset(temp_colordata, 0, 48);
18782
18783
1/2
✓ Branch 0 taken 306215 times.
✗ Branch 1 not taken.
306215 if(!pfread(temp_colordata,48,f))
18784 {
18785 return qe_invalid;
18786 }
18787
18788 306215 memcpy(&colordata[i*48], temp_colordata, 48);
18789 306215 }
18790 }
18791
18792
3/6
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((version < 0x192)||((version == 0x192)&&(build<76)))
18793 {
18794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!should_skip)
18795 4 init_palnames();
18796 4 }
18797 else
18798 {
18799 124 int32_t palnamestoread = 0;
18800
18801
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 112 times.
124 if(s_version < 3)
18802 12 palnamestoread = OLDMAXLEVELS;
18803 else
18804 112 palnamestoread = 512;
18805
18806
2/2
✓ Branch 0 taken 60416 times.
✓ Branch 1 taken 124 times.
60540 for(int32_t i=0; i<palnamestoread; ++i)
18807 {
18808 60416 memset(temp_palname, 0, PALNAMESIZE);
18809
18810
1/2
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
60416 if(!pfread(temp_palname,PALNAMESIZE,f))
18811 {
18812 return qe_invalid;
18813 }
18814
18815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60416 times.
60416 if (!should_skip)
18816 60416 memcpy(palnames[i], temp_palname, PALNAMESIZE);
18817 60416 }
18818
18819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if (should_skip)
18820 return 0;
18821
18822
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 124 times.
3196 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
18823 {
18824 3072 memset(palnames[i], 0, PALNAMESIZE);
18825 3072 }
18826 }
18827
18828
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(version > 0x192)
18829 {
18830
2/2
✓ Branch 0 taken 31744 times.
✓ Branch 1 taken 124 times.
31868 for(int32_t i=0; i<256; i++)
18831 {
18832
2/2
✓ Branch 0 taken 95232 times.
✓ Branch 1 taken 31744 times.
126976 for(int32_t j=0; j<3; j++)
18833 {
18834 95232 temp_misc.cycles[i][j].first=0;
18835 95232 temp_misc.cycles[i][j].count=0;
18836 95232 temp_misc.cycles[i][j].speed=0;
18837 95232 }
18838 31744 }
18839
18840
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&palcycles,f))
18841 {
18842 return qe_invalid;
18843 }
18844
18845
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
124 if (!(palcycles >= 0 && palcycles <= NUM_PAL_CYCLES))
18846 {
18847 return qe_invalid;
18848 }
18849
18850
2/2
✓ Branch 0 taken 3576 times.
✓ Branch 1 taken 124 times.
3700 for(int32_t i=0; i<palcycles; i++)
18851 {
18852
2/2
✓ Branch 0 taken 10728 times.
✓ Branch 1 taken 3576 times.
14304 for(int32_t j=0; j<3; j++)
18853 {
18854
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if(!p_getc(&temp_misc.cycles[i][j].first,f))
18855 {
18856 return qe_invalid;
18857 }
18858 10728 }
18859
18860
2/2
✓ Branch 0 taken 10728 times.
✓ Branch 1 taken 3576 times.
14304 for(int32_t j=0; j<3; j++)
18861 {
18862
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if(!p_getc(&temp_misc.cycles[i][j].count,f))
18863 {
18864 return qe_invalid;
18865 }
18866 10728 }
18867
18868
2/2
✓ Branch 0 taken 10728 times.
✓ Branch 1 taken 3576 times.
14304 for(int32_t j=0; j<3; j++)
18869 {
18870
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
18871 {
18872 return qe_invalid;
18873 }
18874 10728 }
18875 3576 }
18876
18877 124 memcpy(Misc, &temp_misc, sizeof(temp_misc));
18878 124 }
18879
18880 128 return 0;
18881 128 }
18882
18883 128 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
18884 {
18885
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_tiles);
18886
18887 128 int32_t tiles_used=0;
18888 128 word section_version = 0;
18889 128 word section_cversion = 0;
18890 128 int32_t section_size= 0;
18891 128 byte *temp_tile = new byte[tilesize(tf32Bit)];
18892
18893 //Tile Expansion
18894 //if ( version >= 0x254 && build >= 41 )
18895
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
128 if (version < 0x254 && build < 41)
18896 {
18897 //al_trace("Build was < 41 when reading tiles\n");
18898 93 max_tiles = ZC250MAXTILES;
18899 93 }
18900
18901 //al_trace("Max Tiles: %d\n", max_tiles);
18902
18903
2/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
18904 {
18905 if(!init_tiles(true, Header))
18906 {
18907 al_trace("Unable to initialize tiles\n");
18908 }
18909
18910 delete[] temp_tile;
18911 temp_tile=NULL;
18912 return 0;
18913 }
18914 else
18915 {
18916
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(version > 0x192)
18917 {
18918 //section version info
18919
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&section_version,f))
18920 {
18921 delete[] temp_tile;
18922 return qe_invalid;
18923 }
18924
18925 124 FFCore.quest_format[vTiles] = section_version;
18926
18927
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&section_cversion,f))
18928 {
18929 delete[] temp_tile;
18930 return qe_invalid;
18931 }
18932
18933 //section size
18934
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&section_size,f))
18935 {
18936 delete[] temp_tile;
18937 return qe_invalid;
18938 }
18939 124 }
18940
18941 //if ( build < 41 )
18942 //{
18943 // tiles_used = ZC250MAXTILES;
18944 //}
18945
18946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(version < 0x174)
18947 {
18948 tiles_used=TILES_PER_PAGE*4;
18949 } //no expanded tile space
18950
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 else if(version < 0x191)
18951 {
18952 4 tiles_used=OLDMAXTILES;
18953 4 }
18954 else
18955 {
18956 //finally... section data
18957
3/4
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
124 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
18958 {
18959
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tiles_used,f))
18960 {
18961 delete[] temp_tile;
18962 return qe_invalid;
18963 }
18964 35 }
18965 else
18966 {
18967
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 if(!p_igetw(&tiles_used,f))
18968 {
18969 delete[] temp_tile;
18970 return qe_invalid;
18971 }
18972 }
18973 }
18974
18975
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 tiles_used=zc_min(tiles_used, max_tiles);
18976
18977 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
18978 //if ( version < 0x254 && build < 41 )
18979
3/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if ( version < 0x254 || (version == 0x254 && build < 41) )
18980 //if ( build < 41 )
18981 {
18982
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
18983 93 }
18984 else //2.55
18985 {
18986
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
18987 }
18988
18989 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
18990
18991 //al_trace("tiles_used = %d\n", tiles_used);
18992
18993
2/2
✓ Branch 0 taken 3457746 times.
✓ Branch 1 taken 128 times.
3457874 for(int32_t i=0; i<tiles_used; ++i)
18994 {
18995 3457746 byte format=tf4Bit;
18996 3457746 memset(temp_tile, 0, tilesize(tf32Bit));
18997
18998
3/6
✓ Branch 0 taken 630780 times.
✓ Branch 1 taken 2826966 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 630780 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3457746 if((version>0x211)||((version==0x211)&&(build>4)))
18999 {
19000
1/2
✓ Branch 0 taken 2826966 times.
✗ Branch 1 not taken.
2826966 if(!p_getc(&format,f))
19001 {
19002 delete[] temp_tile;
19003 return qe_invalid;
19004 }
19005 2826966 }
19006
4/4
✓ Branch 0 taken 1277412 times.
✓ Branch 1 taken 2180334 times.
✓ Branch 2 taken 592329 times.
✓ Branch 3 taken 685083 times.
3457746 if(section_version > 2 && !format)
19007 {
19008 685083 reset_tile(buf,start_tile+i,tf4Bit);
19009 685083 continue;
19010 }
19011
19012
1/2
✓ Branch 0 taken 2772663 times.
✗ Branch 1 not taken.
2772663 if(!pfread(temp_tile,tilesize(format),f))
19013 {
19014 delete[] temp_tile;
19015 return qe_invalid;
19016 }
19017
19018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2772663 times.
2772663 if (should_skip)
19019 continue;
19020
19021 2772663 buf[start_tile+i].format=format;
19022
19023
1/2
✓ Branch 0 taken 2772663 times.
✗ Branch 1 not taken.
2772663 if(buf[start_tile+i].data)
19024 {
19025 2772663 free(buf[start_tile+i].data);
19026 2772663 buf[start_tile+i].data=NULL;
19027 2772663 }
19028
19029 2772663 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19030 2772663 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19031 2772663 }
19032 }
19033
19034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (should_skip)
19035 return 0;
19036
19037
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19038 {
19039 //al_trace("Writing blank tile data to new tiles for build < 41\n");
19040
2/2
✓ Branch 0 taken 13855140 times.
✓ Branch 1 taken 93 times.
13855233 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19041 {
19042
19043 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19044 13855140 reset_tile(buf,q,tf4Bit);
19045
19046
19047 /*
19048
19049 byte tempbyte;
19050 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19051 {
19052 tempbyte=buf[ZC250MAXTILES-1].data[i];
19053 buf[q].data[i] = tempbyte;
19054 }
19055 //int32_t temp = tempbyte=buf[130].data[i];
19056 //buf[q].data = buf[ZC250MAXTILES-1].data;
19057 */
19058 //reset_tile(buf,q,tf4Bit);
19059 13855140 }
19060
19061 93 }
19062
19063
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19064 {
19065
2/2
✓ Branch 0 taken 4121646 times.
✓ Branch 1 taken 93 times.
4121739 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19066 {
19067 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
19068 4121646 reset_tile(buf,i,tf4Bit);
19069 4121646 }
19070 93 }
19071 else
19072 {
19073
2/2
✓ Branch 0 taken 6021468 times.
✓ Branch 1 taken 35 times.
6021503 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19074 {
19075 //al_trace("Resetting tiles for build 41+\n");
19076 6021468 reset_tile(buf,i,tf4Bit);
19077 6021468 }
19078 }
19079
19080
3/6
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19081 {
19082
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_qr(qr_BSZELDA)) //
19083 {
19084 byte tempbyte;
19085 int32_t floattile=wpnsbuf[iwSwim].tile;
19086
19087 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19088 {
19089 tempbyte=buf[23].data[i];
19090 buf[23].data[i]=buf[24].data[i];
19091 buf[24].data[i]=buf[25].data[i];
19092 buf[25].data[i]=buf[26].data[i];
19093 buf[26].data[i]=tempbyte;
19094 }
19095 //swim tiles are out of order, too, but nobody cared? -Z
19096 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19097 {
19098 tempbyte=buf[floattile+11].data[i];
19099 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19100 buf[floattile+12].data[i]=tempbyte;
19101 }
19102 }
19103 4 }
19104
19105
3/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19106 {
19107
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 if(!get_qr(qr_NEWENEMYTILES))
19108 {
19109 byte tempbyte;
19110
19111
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19112 {
19113 512 tempbyte=buf[130].data[i];
19114 512 buf[130].data[i]=buf[132].data[i];
19115 512 buf[132].data[i]=tempbyte;
19116
19117 512 tempbyte=buf[131].data[i];
19118 512 buf[131].data[i]=buf[133].data[i];
19119 512 buf[133].data[i]=tempbyte;
19120 512 }
19121 4 }
19122 16 }
19123
19124 128 al_trace("Registering blank tiles\n");
19125 128 register_blank_tiles();
19126
19127 //memset(temp_tile, 0, tilesize(tf32Bit));
19128
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 delete[] temp_tile;
19129 128 temp_tile=NULL;
19130 128 return 0;
19131 128 }
19132
19133 128 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
19134 {
19135
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_midis);
19136
19137 static byte fake_midi_flags[32];
19138
19139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 byte *mf=should_skip ? fake_midi_flags : midi_flags;
19140 int32_t dummy;
19141 word dummy2;
19142 // zcmidi_ temp_midi;
19143 int32_t tunes_to_read;
19144 128 int32_t tune_count=0;
19145 128 word section_version=0;
19146 128 zctune temp;
19147
19148
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(Header->zelda_version < 0x193)
19149 {
19150 // mf=Header->data_flags+ZQ_MIDIS2;
19151
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19152 {
19153 4 tunes_to_read=MAXCUSTOMMIDIS192b177;
19154 4 }
19155 else
19156 {
19157 tunes_to_read=MAXCUSTOMTUNES;
19158 }
19159 4 }
19160 else
19161 {
19162 //section version info
19163
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&section_version,f))
19164 {
19165 return qe_invalid;
19166 }
19167
19168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if (!should_skip)
19169 124 FFCore.quest_format[vMIDIs] = section_version;
19170
19171 //al_trace("Tunes version %d\n", section_version);
19172
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&dummy2,f))
19173 {
19174 return qe_invalid;
19175 }
19176
19177 //section size
19178
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&dummy,f))
19179 {
19180 return qe_invalid;
19181 }
19182
19183 //finally... section data
19184
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!pfread(midi_flags,sizeof(midi_flags),f))
19185 {
19186 return qe_invalid;
19187 }
19188
19189 124 tunes_to_read=MAXCUSTOMTUNES;
19190 }
19191
19192
2/2
✓ Branch 0 taken 32256 times.
✓ Branch 1 taken 128 times.
32384 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19193 {
19194
2/2
✓ Branch 0 taken 2301 times.
✓ Branch 1 taken 29955 times.
32256 if(get_bit(mf, i))
19195 {
19196 2301 ++tune_count;
19197 2301 }
19198 32256 }
19199
19200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (!should_skip)
19201 128 reset_tunes(tunes); //reset_midis(midis);
19202
19203
2/2
✓ Branch 0 taken 31376 times.
✓ Branch 1 taken 128 times.
31504 for(int32_t i=0; i<tunes_to_read; i++)
19204 {
19205 31376 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19206
19207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31376 times.
31376 if (!should_skip)
19208 31376 tunes[i].reset(); // reset_midi(midis+i);
19209
19210
2/2
✓ Branch 0 taken 29075 times.
✓ Branch 1 taken 2301 times.
31376 if(get_bit(mf,i))
19211 {
19212
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1584 times.
2301 if(section_version < 4)
19213 {
19214
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if(!pfread(&temp.title,sizeof(char)*20,f))
19215 {
19216 return qe_invalid;
19217 }
19218 717 }
19219 else
19220 {
19221
1/2
✓ Branch 0 taken 1584 times.
✗ Branch 1 not taken.
1584 if(!pfread(&temp.title,sizeof(temp.title),f))
19222 {
19223 return qe_invalid;
19224 }
19225 }
19226
19227
1/2
✓ Branch 0 taken 2301 times.
✗ Branch 1 not taken.
2301 if(!p_igetl(&temp.start,f))
19228 {
19229 return qe_invalid;
19230 }
19231
19232
1/2
✓ Branch 0 taken 2301 times.
✗ Branch 1 not taken.
2301 if(!p_igetl(&temp.loop_start,f))
19233 {
19234 return qe_invalid;
19235 }
19236
19237
1/2
✓ Branch 0 taken 2301 times.
✗ Branch 1 not taken.
2301 if(!p_igetl(&temp.loop_end,f))
19238 {
19239 return qe_invalid;
19240 }
19241
19242
1/2
✓ Branch 0 taken 2301 times.
✗ Branch 1 not taken.
2301 if(!p_igetw(&temp.loop,f))
19243 {
19244 return qe_invalid;
19245 }
19246
19247
1/2
✓ Branch 0 taken 2301 times.
✗ Branch 1 not taken.
2301 if(!p_igetw(&temp.volume,f))
19248 {
19249 return qe_invalid;
19250 }
19251
19252
2/2
✓ Branch 0 taken 2223 times.
✓ Branch 1 taken 78 times.
2301 if(Header->zelda_version < 0x193)
19253 {
19254
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 if(!p_igetl(&dummy,f))
19255 {
19256 return qe_invalid;
19257 }
19258 78 }
19259
19260
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1584 times.
2301 if(section_version >= 3)
19261 {
19262
1/2
✓ Branch 0 taken 1584 times.
✗ Branch 1 not taken.
1584 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19263 {
19264 return qe_invalid;
19265 }
19266 1584 }
19267
19268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2301 times.
2301 if (!should_skip)
19269 2301 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19270
19271
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1584 times.
2301 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19272 {
19273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 717 times.
717 if (should_skip)
19274 {
19275 if (read_midi(f)==NULL)
19276 {
19277 return qe_invalid;
19278 }
19279
19280 continue;
19281 }
19282
19283 // old format - a midi is a midi
19284
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if((tunes[i].data=read_midi(f))==NULL)
19285 {
19286 return qe_invalid;
19287 }
19288
19289 //yes you can do this. Isn't the ? operator awesome? :)
19290 717 tunes[i].format = MFORMAT_MIDI;
19291 717 }
19292 else
19293 {
19294 // 'midi' could be midi or nes, gb, ... music
19295
1/2
✓ Branch 0 taken 1584 times.
✗ Branch 1 not taken.
1584 if(!pfread(&tunes[i].format,sizeof(tunes[i].format),f))
19296 {
19297 return qe_invalid;
19298 }
19299
19300 1584 zctune *ptr = &tunes[i];
19301
19302
1/2
✓ Branch 0 taken 1584 times.
✗ Branch 1 not taken.
1584 switch(temp.format)
19303 {
19304 case MFORMAT_MIDI:
19305
1/2
✓ Branch 0 taken 1584 times.
✗ Branch 1 not taken.
1584 if((ptr->data=read_midi(f))==NULL)
19306 {
19307 return qe_invalid;
19308 }
19309
19310 1584 break;
19311
19312 default:
19313 return qe_invalid;
19314 break;
19315 }
19316 }
19317 2301 }
19318 31376 }
19319
19320 128 return 0;
19321 128 }
19322
19323 128 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19324 {
19325
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_cheats);
19326
19327 int32_t dummy;
19328 ZCHEATS tempzcheats;
19329 128 char temp_use_cheats=1;
19330 128 memset(&tempzcheats, 0, sizeof(tempzcheats));
19331 128 word s_version = 0;
19332
19333
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(Header->zelda_version > 0x192)
19334 {
19335 //section version info
19336
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&s_version,f))
19337 {
19338 return qe_invalid;
19339 }
19340
19341 124 FFCore.quest_format[vCheats] = s_version;
19342 //al_trace("Cheats version %d\n", dummy);
19343
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&dummy,f))
19344 {
19345 return qe_invalid;
19346 }
19347
19348 //section size
19349
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&dummy,f))
19350 {
19351 return qe_invalid;
19352 }
19353
19354 //finally... section data
19355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(!p_getc(&temp_use_cheats,f))
19356 {
19357 return qe_invalid;
19358 }
19359 124 }
19360
19361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(Header->data_flags[ZQ_CHEATS2])
19362 {
19363
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_igetl(&tempzcheats.flags,f))
19364 {
19365 return qe_invalid;
19366 }
19367
19368
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19369 {
19370 return qe_invalid;
19371 }
19372 128 }
19373
19374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (should_skip)
19375 return 0;
19376
19377 128 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19378 128 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19379
19380 128 return 0;
19381 128 }
19382
19383 284 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
19384 {
19385
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 4 times.
284 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
19386
19387 int32_t dummy;
19388 284 word s_version=0, s_cversion=0;
19389 byte padding;
19390
19391 284 zinitdata temp_zinit = {};
19392
19393 // Legacy item properties (now integrated into itemdata)
19394 byte sword_hearts[4];
19395 byte beam_hearts[4];
19396 284 byte beam_percent=0;
19397 word beam_power[4];
19398 284 byte hookshot_length=99;
19399 284 byte hookshot_links=100;
19400 284 byte longshot_length=99;
19401 284 byte longshot_links=100;
19402 284 byte moving_fairy_hearts=3;
19403 284 byte moving_fairy_heart_percent=0;
19404 284 byte stationary_fairy_hearts=3;
19405 284 byte stationary_fairy_heart_percent=0;
19406 284 byte moving_fairy_magic=0;
19407 284 byte moving_fairy_magic_percent=0;
19408 284 byte stationary_fairy_magic=0;
19409 284 byte stationary_fairy_magic_percent=0;
19410 284 byte blue_potion_hearts=100;
19411 284 byte blue_potion_heart_percent=1;
19412 284 byte red_potion_hearts=100;
19413 284 byte red_potion_heart_percent=1;
19414 284 byte blue_potion_magic=100;
19415 284 byte blue_potion_magic_percent=1;
19416 284 byte red_potion_magic=100;
19417 284 byte red_potion_magic_percent=1;
19418
19419
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 156 times.
284 temp_zinit.subscreen_style=get_qr(qr_COOLSCROLL)?1:0;
19420
19421
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if(Header->zelda_version > 0x192)
19422 {
19423 //section version info
19424
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetw(&s_version,f))
19425 {
19426 return qe_invalid;
19427 }
19428
19429 124 FFCore.quest_format[vInitData] = s_version;
19430
19431 //al_trace("Init data version %d\n", s_version);
19432
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetw(&s_cversion,f))
19433 {
19434 return qe_invalid;
19435 }
19436
19437 //section size
19438
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetl(&dummy,f))
19439 {
19440 return qe_invalid;
19441 }
19442 124 }
19443
19444 /* HIGHLY UNORTHODOX UPDATING THING, by L
19445 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19446 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19447 * changing from 13 to 14.
19448 */
19449
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version < 14)
19450 16 fixpolsvoice=true;
19451
19452 /* End highly unorthodox updating thing */
19453
19454
5/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 75 times.
✓ Branch 5 taken 37 times.
128 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19455 37 temp_zinit.jump_hero_layer_threshold=0;
19456
19457
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 112 times.
128 if(s_version >= 10)
19458 {
19459 char temp;
19460
19461 //new-style items
19462
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 112 times.
28784 for(int32_t j=0; j<256; j++)
19463 {
19464
2/4
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 28672 times.
28672 if(!p_getc(&temp,f))
19465 return qe_invalid;
19466
19467 28672 temp_zinit.items[j] = (temp != 0);
19468 28672 }
19469 112 }
19470
19471
5/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 32 times.
128 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19472 {
19473 char temp;
19474
19475 //finally... section data
19476
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 32 times.
156 if((Header->zelda_version > 0x192)||
19477 //new only
19478 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19479 {
19480 //OLD-style items... sigh
19481
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 112 times.
124 if(s_version < 10)
19482 {
19483
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19484 {
19485 return qe_invalid;
19486 }
19487
19488 12 temp_zinit.items[iRaft]=(temp != 0);
19489
19490
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19491 {
19492 return qe_invalid;
19493 }
19494
19495 12 temp_zinit.items[iLadder]=(temp != 0);
19496
19497
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19498 {
19499 return qe_invalid;
19500 }
19501
19502 12 temp_zinit.items[iBook]=(temp != 0);
19503
19504
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19505 {
19506 return qe_invalid;
19507 }
19508
19509 12 temp_zinit.items[iMKey]=(temp!=0);
19510
19511
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19512 {
19513 return qe_invalid;
19514 }
19515
19516 12 temp_zinit.items[iFlippers]=(temp != 0);
19517
19518
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19519 {
19520 return qe_invalid;
19521 }
19522
19523 12 temp_zinit.items[iBoots]=(temp!=0);
19524 12 }
19525 124 }
19526
19527
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 142 times.
156 if(s_version < 10)
19528 {
19529 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19530
19531
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempring,f))
19532 {
19533 return qe_invalid;
19534 }
19535
19536
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempsword,f))
19537 {
19538 return qe_invalid;
19539 }
19540
19541
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempshield,f))
19542 {
19543 return qe_invalid;
19544 }
19545
19546
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempwallet,f))
19547 {
19548 return qe_invalid;
19549 }
19550
19551
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempbracelet,f))
19552 {
19553 return qe_invalid;
19554 }
19555
19556
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempamulet,f))
19557 {
19558 return qe_invalid;
19559 }
19560
19561
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempbow,f))
19562 {
19563 return qe_invalid;
19564 }
19565
19566 //old only
19567
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build<174))
19568 {
19569 tempring=(tempring)?(1<<(tempring-1)):0;
19570 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19571 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19572 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19573 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19574 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19575 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19576 }
19577
19578 //rings start at level 2... wtf
19579 //account for this -DD
19580 12 tempring <<= 1;
19581
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19582
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19583
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19584
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19585 //bracelet ALSO starts at level 2 :-( -DD
19586 12 tempbracelet<<=1;
19587
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19588
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19589
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19590
19591 //new only
19592
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build>173))
19593 {
19594 for(int32_t q=0; q<32; q++)
19595 {
19596 if(!p_getc(&padding,f))
19597 {
19598 return qe_invalid;
19599 }
19600 }
19601 }
19602
19603 char tempcandle, tempboomerang, temparrow, tempwhistle;
19604
19605
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempcandle,f))
19606 {
19607 return qe_invalid;
19608 }
19609
19610
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempboomerang,f))
19611 {
19612 return qe_invalid;
19613 }
19614
19615
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temparrow,f))
19616 {
19617 return qe_invalid;
19618 }
19619
19620
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19621 {
19622 return qe_invalid;
19623 }
19624
19625
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19626
19627
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempwhistle,f))
19628 {
19629 return qe_invalid;
19630 }
19631
19632 //old only
19633
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build<174))
19634 {
19635 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19636 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19637 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19638 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19639 }
19640
19641
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19642
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19643
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19644
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19645 //What about the potion...?
19646
19647 12 }
19648
19649
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 65 times.
154 if(s_version < 29)
19650 {
19651 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19652 //to jab out my eye...
19653
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
89 if(!p_getc(&padding,f))
19654 return qe_invalid;
19655 89 temp_zinit.bombs = padding;
19656
19657
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
89 if(!p_getc(&padding,f))
19658 return qe_invalid;
19659 89 temp_zinit.super_bombs = padding;
19660 89 }
19661
19662 //Back to more OLD item code
19663
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
154 if(s_version < 10)
19664 {
19665
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version > 0x192)||
19666 //new only
19667 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19668 {
19669
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19670 {
19671 return qe_invalid;
19672 }
19673
19674
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19675
19676
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19677 {
19678 return qe_invalid;
19679 }
19680
19681
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19682
19683
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19684 {
19685 return qe_invalid;
19686 }
19687
19688
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19689
19690
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19691 {
19692 return qe_invalid;
19693 }
19694
19695
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19696
19697
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19698 {
19699 return qe_invalid;
19700 }
19701
19702
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19703
19704
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19705 {
19706 return qe_invalid;
19707 }
19708
19709
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19710
19711
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19712 {
19713 return qe_invalid;
19714 }
19715
19716
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19717
19718
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19719 {
19720 return qe_invalid;
19721 }
19722
19723
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19724
19725
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19726 {
19727 return qe_invalid;
19728 }
19729
19730
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19731
19732
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19733 {
19734 return qe_invalid;
19735 }
19736
19737
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(Header->zelda_version == 0x192)
19738 {
19739 for(int32_t q=0; q<32; q++)
19740 {
19741 if(!p_getc(&padding,f))
19742 {
19743 return qe_invalid;
19744 }
19745 }
19746 }
19747 12 }
19748 12 }
19749
19750 //old only
19751
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
24 if((Header->zelda_version == 0x192)&&(Header->build<174))
19752 {
19753 byte equipment, items; //bit flags
19754
19755 if(!p_getc(&equipment,f))
19756 {
19757 return qe_invalid;
19758 }
19759
19760 temp_zinit.items[iRaft]=(get_bit(&equipment, idE_RAFT)!=0);
19761 temp_zinit.items[iLadder]=(get_bit(&equipment, idE_LADDER)!=0);
19762 temp_zinit.items[iBook]=(get_bit(&equipment, idE_BOOK)!=0);
19763 temp_zinit.items[iMKey]=(get_bit(&equipment, idE_KEY)!=0);
19764 temp_zinit.items[iFlippers]=(get_bit(&equipment, idE_FLIPPERS)!=0);
19765 temp_zinit.items[iBoots]=(get_bit(&equipment, idE_BOOTS)!=0);
19766
19767
19768 if(!p_getc(&items,f))
19769 {
19770 return qe_invalid;
19771 }
19772
19773 temp_zinit.items[iWand]=(get_bit(&items, idI_WAND)!=0);
19774 temp_zinit.items[iLetter]=(get_bit(&items, idI_LETTER)!=0);
19775 temp_zinit.items[iLens]=(get_bit(&items, idI_LENS)!=0);
19776 temp_zinit.items[iHookshot]=(get_bit(&items, idI_HOOKSHOT)!=0);
19777 temp_zinit.items[iBait]=(get_bit(&items, idI_BAIT)!=0);
19778 temp_zinit.items[iHammer]=(get_bit(&items, idI_HAMMER)!=0);
19779 }
19780
19781 if(!p_getc(&temp_zinit.hc,f))
19782 {
19783 return qe_invalid;
19784 }
19785
19786
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 112 times.
124 if(s_version < 14)
19787 {
19788 byte temphp;
19789
19790
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temphp,f))
19791 {
19792 return qe_invalid;
19793 }
19794
19795 12 temp_zinit.start_heart=temphp;
19796
19797
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temphp,f))
19798 {
19799 return qe_invalid;
19800 }
19801
19802 12 temp_zinit.cont_heart=temphp;
19803 12 }
19804 else
19805 {
19806
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_igetw(&temp_zinit.start_heart,f))
19807 {
19808 return qe_invalid;
19809 }
19810
19811
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_igetw(&temp_zinit.cont_heart,f))
19812 {
19813 return qe_invalid;
19814 }
19815 }
19816
19817
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_getc(&temp_zinit.hcp,f))
19818 {
19819 return qe_invalid;
19820 }
19821
19822
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 12 times.
124 if(s_version >= 14)
19823 {
19824
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_getc(&temp_zinit.hcp_per_hc,f))
19825 {
19826 return qe_invalid;
19827 }
19828
19829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(s_version<16) // July 2007
19830 {
19831 if(get_qr(qr_BRANGPICKUP+1))
19832 temp_zinit.hcp_per_hc = 0xFF;
19833
19834 //Dispose of legacy rule
19835 set_qr(qr_BRANGPICKUP+1, 0);
19836 }
19837 112 }
19838
19839
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 35 times.
124 if(s_version < 29)
19840 {
19841
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
89 if(!p_getc(&padding,f))
19842 return qe_invalid;
19843 89 temp_zinit.max_bombs = padding;
19844 89 }
19845
19846
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_getc(&temp_zinit.keys,f))
19847 {
19848 return qe_invalid;
19849 }
19850
19851
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetw(&temp_zinit.rupies,f))
19852 {
19853 return qe_invalid;
19854 }
19855
19856
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_getc(&temp_zinit.triforce,f))
19857 {
19858 return qe_invalid;
19859 }
19860
19861
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
124 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19862 {
19863
2/2
✓ Branch 0 taken 7168 times.
✓ Branch 1 taken 112 times.
7280 for(int32_t i=0; i<64; i++)
19864 {
19865
2/4
✓ Branch 0 taken 7168 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7168 times.
7168 if(!p_getc(&temp_zinit.map[i],f))
19866 {
19867 return qe_invalid;
19868 }
19869 7168 }
19870
19871
2/2
✓ Branch 0 taken 7168 times.
✓ Branch 1 taken 112 times.
7280 for(int32_t i=0; i<64; i++)
19872 {
19873
2/4
✓ Branch 0 taken 7168 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7168 times.
7168 if(!p_getc(&temp_zinit.compass[i],f))
19874 {
19875 return qe_invalid;
19876 }
19877 7168 }
19878 112 }
19879 else
19880 {
19881
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19882 {
19883
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
384 if(!p_getc(&temp_zinit.map[i],f))
19884 {
19885 return qe_invalid;
19886 }
19887 384 }
19888
19889
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19890 {
19891
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
384 if(!p_getc(&temp_zinit.compass[i],f))
19892 {
19893 return qe_invalid;
19894 }
19895 384 }
19896 }
19897
19898
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
124 if((Header->zelda_version > 0x192)||
19899 //new only
19900 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19901 {
19902
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
124 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19903 {
19904
2/2
✓ Branch 0 taken 7168 times.
✓ Branch 1 taken 112 times.
7280 for(int32_t i=0; i<64; i++)
19905 {
19906
2/4
✓ Branch 0 taken 7168 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7168 times.
7168 if(!p_getc(&temp_zinit.boss_key[i],f))
19907 {
19908 return qe_invalid;
19909 }
19910 7168 }
19911 112 }
19912 else
19913 {
19914
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19915 {
19916
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 384 times.
✗ Branch 3 not taken.
384 if(!p_getc(&temp_zinit.boss_key[i],f))
19917 {
19918 return qe_invalid;
19919 }
19920 384 }
19921 }
19922 124 }
19923
19924
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 1984 times.
2108 for(int32_t i=0; i<16; i++)
19925 {
19926
2/4
✓ Branch 0 taken 1984 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1984 times.
1984 if(!p_getc(&temp_zinit.misc[i],f))
19927 {
19928 return qe_invalid;
19929 }
19930 1984 }
19931
19932
4/4
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 12 times.
172 if(s_version < 15) for(int32_t i=0; i<4; i++)
19933 {
19934
2/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
48 if(!p_getc(&sword_hearts[i],f))
19935 {
19936 return qe_invalid;
19937 }
19938 60 }
19939
19940
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_getc(&temp_zinit.last_map,f))
19941 {
19942 return qe_invalid;
19943 }
19944
19945
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_getc(&temp_zinit.last_screen,f))
19946 {
19947 return qe_invalid;
19948 }
19949
19950
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 112 times.
124 if(s_version < 14)
19951 {
19952 byte tempmp;
19953
19954
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempmp,f))
19955 {
19956 return qe_invalid;
19957 }
19958
19959 12 temp_zinit.max_magic=tempmp;
19960
19961
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempmp,f))
19962 {
19963 return qe_invalid;
19964 }
19965
19966 12 temp_zinit.magic=tempmp;
19967 12 }
19968 else
19969 {
19970
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_igetw(&temp_zinit.max_magic,f))
19971 {
19972 return qe_invalid;
19973 }
19974
19975
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_igetw(&temp_zinit.magic,f))
19976 {
19977 return qe_invalid;
19978 }
19979 }
19980
19981
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 12 times.
124 if(s_version < 15)
19982 {
19983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(s_version < 12)
19984 {
19985 12 temp_zinit.max_magic*=32;
19986 12 temp_zinit.magic*=32;
19987 12 }
19988
19989
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 48 times.
60 for(int32_t i=0; i<4; i++)
19990 {
19991
2/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
48 if(!p_getc(&beam_hearts[i],f))
19992 {
19993 return qe_invalid;
19994 }
19995 48 }
19996
19997
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&beam_percent,f))
19998 {
19999 return qe_invalid;
20000 }
20001 12 }
20002 else
20003 {
20004
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_getc(&temp_zinit.bomb_ratio,f))
20005 {
20006 return qe_invalid;
20007 }
20008 }
20009
20010
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 12 times.
124 if(s_version < 15)
20011 {
20012 byte tempbp;
20013
20014
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 48 times.
60 for(int32_t i=0; i<4; i++)
20015 {
20016
3/8
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
48 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
20017 {
20018 return qe_invalid;
20019 }
20020
20021 48 beam_power[i]=tempbp;
20022 48 }
20023
20024
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&hookshot_links,f))
20025 {
20026 return qe_invalid;
20027 }
20028
20029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(s_version>6)
20030 {
20031 if(!p_getc(&hookshot_length,f))
20032 {
20033 return qe_invalid;
20034 }
20035
20036 if(!p_getc(&longshot_links,f))
20037 {
20038 return qe_invalid;
20039 }
20040
20041 if(!p_getc(&longshot_length,f))
20042 {
20043 return qe_invalid;
20044 }
20045 }
20046 12 }
20047
20048
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_getc(&temp_zinit.msg_more_x,f))
20049 {
20050 return qe_invalid;
20051 }
20052
20053
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_getc(&temp_zinit.msg_more_y,f))
20054 {
20055 return qe_invalid;
20056 }
20057
20058
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_getc(&temp_zinit.subscreen,f))
20059 {
20060 return qe_invalid;
20061 }
20062
20063 //old only
20064
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
124 if((Header->zelda_version == 0x192)&&(Header->build<174))
20065 {
20066 for(int32_t i=0; i<32; i++)
20067 {
20068 if(!p_getc(&temp_zinit.boss_key[i],f))
20069 {
20070 return qe_invalid;
20071 }
20072 }
20073 }
20074
20075
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
124 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20076 {
20077
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 112 times.
124 if(s_version <= 10)
20078 {
20079 byte tempbyte;
20080
20081
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempbyte,f))
20082 {
20083 return qe_invalid;
20084 }
20085
20086 12 temp_zinit.start_dmap = (word)tempbyte;
20087 12 }
20088 else
20089 {
20090
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_igetw(&temp_zinit.start_dmap,f))
20091 {
20092 return qe_invalid;
20093 }
20094 }
20095
20096
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20097 {
20098 return qe_invalid;
20099 }
20100 124 }
20101
20102
4/4
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 35 times.
124 if(s_version>1 && s_version < 29)
20103 {
20104
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if(!p_getc(&padding,f))
20105 return qe_invalid;
20106 77 temp_zinit.arrows = padding;
20107
20108
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if(!p_getc(&padding,f))
20109 return qe_invalid;
20110 77 temp_zinit.max_arrows = padding;
20111 77 }
20112
20113
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 112 times.
124 if(s_version>2)
20114 {
20115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(s_version <= 10)
20116 {
20117 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20118 {
20119 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20120 {
20121 return qe_invalid;
20122 }
20123 }
20124 }
20125 else
20126 {
20127
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 112 times.
57456 for(int32_t i=0; i<MAXLEVELS; i++)
20128 {
20129
2/4
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57344 times.
✗ Branch 3 not taken.
57344 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20130 {
20131 return qe_invalid;
20132 }
20133 57344 }
20134 }
20135 112 }
20136
20137
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 12 times.
124 if(s_version>3)
20138 {
20139
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_igetw(&temp_zinit.ss_grid_x,f))
20140 {
20141 return qe_invalid;
20142 }
20143
20144
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_igetw(&temp_zinit.ss_grid_y,f))
20145 {
20146 return qe_invalid;
20147 }
20148
20149
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
20150 {
20151 return qe_invalid;
20152 }
20153
20154
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
20155 {
20156 return qe_invalid;
20157 }
20158
20159
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_igetw(&temp_zinit.ss_grid_color,f))
20160 {
20161 return qe_invalid;
20162 }
20163
20164
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
20165 {
20166 return qe_invalid;
20167 }
20168
20169
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
20170 {
20171 return qe_invalid;
20172 }
20173
20174
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_igetw(&temp_zinit.ss_flags,f))
20175 {
20176 return qe_invalid;
20177 }
20178
20179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20181 112 }
20182
20183
3/4
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
124 if(s_version>4 && s_version<15)
20184 {
20185 if(!p_getc(&moving_fairy_hearts,f))
20186 {
20187 return qe_invalid;
20188 }
20189
20190 if(!p_getc(&moving_fairy_heart_percent,f))
20191 {
20192 return qe_invalid;
20193 }
20194 }
20195
20196
3/4
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
124 if(s_version>5 && s_version < 10)
20197 {
20198 if(!p_getc(&temp,f))
20199 {
20200 return qe_invalid;
20201 }
20202
20203 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20204 }
20205
20206
3/4
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
124 if(s_version>6 && s_version<15)
20207 {
20208 if(!p_getc(&stationary_fairy_hearts,f))
20209 {
20210 return qe_invalid;
20211 }
20212
20213 if(!p_getc(&stationary_fairy_heart_percent,f))
20214 {
20215 return qe_invalid;
20216 }
20217
20218 if(!p_getc(&moving_fairy_magic,f))
20219 {
20220 return qe_invalid;
20221 }
20222
20223 if(!p_getc(&moving_fairy_magic_percent,f))
20224 {
20225 return qe_invalid;
20226 }
20227
20228 if(!p_getc(&stationary_fairy_magic,f))
20229 {
20230 return qe_invalid;
20231 }
20232
20233 if(!p_getc(&stationary_fairy_magic_percent,f))
20234 {
20235 return qe_invalid;
20236 }
20237
20238 if(!p_getc(&blue_potion_hearts,f))
20239 {
20240 return qe_invalid;
20241 }
20242
20243 if(!p_getc(&blue_potion_heart_percent,f))
20244 {
20245 return qe_invalid;
20246 }
20247
20248 if(!p_getc(&red_potion_hearts,f))
20249 {
20250 return qe_invalid;
20251 }
20252
20253 if(!p_getc(&red_potion_heart_percent,f))
20254 {
20255 return qe_invalid;
20256 }
20257
20258 if(!p_getc(&blue_potion_magic,f))
20259 {
20260 return qe_invalid;
20261 }
20262
20263 if(!p_getc(&blue_potion_magic_percent,f))
20264 {
20265 return qe_invalid;
20266 }
20267
20268 if(!p_getc(&red_potion_magic,f))
20269 {
20270 return qe_invalid;
20271 }
20272
20273 if(!p_getc(&red_potion_magic_percent,f))
20274 {
20275 return qe_invalid;
20276 }
20277 }
20278
20279
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 12 times.
124 if(s_version>6)
20280 {
20281
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_getc(&temp_zinit.subscreen_style,f))
20282 {
20283 return qe_invalid;
20284 }
20285 112 }
20286
20287
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 12 times.
124 if(s_version>7)
20288 {
20289
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_getc(&temp_zinit.usecustomsfx,f))
20290 {
20291 return qe_invalid;
20292 }
20293 112 }
20294
20295
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 12 times.
124 if(s_version>8)
20296 {
20297
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_igetw(&temp_zinit.max_rupees,f))
20298 {
20299 return qe_invalid;
20300 }
20301
20302
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_igetw(&temp_zinit.max_keys,f))
20303 {
20304 return qe_invalid;
20305 }
20306 112 }
20307
20308
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 12 times.
124 if(s_version>16)
20309 {
20310
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_getc(&temp_zinit.gravity,f))
20311 {
20312 return qe_invalid;
20313 }
20314
20315
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_igetw(&temp_zinit.terminalv,f))
20316 {
20317 return qe_invalid;
20318 }
20319
20320
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_getc(&temp_zinit.msg_speed,f))
20321 {
20322 return qe_invalid;
20323 }
20324
20325
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_getc(&temp_zinit.transition_type,f))
20326 {
20327 return qe_invalid;
20328 }
20329
20330
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20331 {
20332 return qe_invalid;
20333 }
20334 112 }
20335
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 else if (replay_version_check(0, 13))
20336 12 temp_zinit.msg_speed = 0;
20337
20338
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 12 times.
124 if(s_version>17)
20339 {
20340
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20341 {
20342 return qe_invalid;
20343 }
20344 112 }
20345
20346 //expaned init data for larger values in 2.55
20347
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 89 times.
124 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20348 {
20349
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_igetw(&temp_zinit.bombs,f))
20350 {
20351 return qe_invalid;
20352 }
20353
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_igetw(&temp_zinit.super_bombs,f))
20354 {
20355 return qe_invalid;
20356 }
20357
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_igetw(&temp_zinit.max_bombs,f))
20358 {
20359 return qe_invalid;
20360 }
20361
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_igetw(&temp_zinit.max_sbombs,f))
20362 {
20363 return qe_invalid;
20364 }
20365
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_igetw(&temp_zinit.arrows,f))
20366 {
20367 return qe_invalid;
20368 }
20369
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_igetw(&temp_zinit.max_arrows,f))
20370 {
20371 return qe_invalid;
20372 }
20373
20374 35 }
20375
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 89 times.
124 if ( s_version >= 20 )
20376 {
20377
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_igetw(&temp_zinit.heroStep,f))
20378 {
20379 return qe_invalid;
20380 }
20381 35 }
20382 else
20383 {
20384 89 temp_zinit.heroStep = 150; //1.5 pixels per frame
20385 }
20386
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 89 times.
124 if ( s_version >= 21 )
20387 {
20388
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20389 {
20390 return qe_invalid;
20391 }
20392 35 }
20393 else
20394 {
20395 89 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20396 }
20397 //old only
20398
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
124 if((Header->zelda_version == 0x192)&&(Header->build<174))
20399 {
20400 byte items2;
20401
20402 if(!p_getc(&items2,f))
20403 {
20404 return qe_invalid;
20405 }
20406
20407 temp_zinit.items[iDivineFire]=(get_bit(&items2, idI_DFIRE)!=0);
20408 temp_zinit.items[iDivineEscape]=(get_bit(&items2, idI_FWIND)!=0);
20409 temp_zinit.items[iDivineProtection]=(get_bit(&items2, idI_NLOVE)!=0);
20410 }
20411
20412
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(Header->zelda_version < 0x193)
20413 {
20414 for(int32_t q=0; q<96; q++)
20415 {
20416 if(!p_getc(&padding,f))
20417 {
20418 return qe_invalid;
20419 }
20420 }
20421
20422 //new only
20423 if((Header->zelda_version == 0x192)&&(Header->build>173))
20424 {
20425 if(!p_getc(&padding,f))
20426 {
20427 return qe_invalid;
20428 }
20429
20430 if(!p_getc(&padding,f))
20431 {
20432 return qe_invalid;
20433 }
20434 }
20435 }
20436 124 }
20437
20438
3/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
160 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20439 {
20440 //temp_zinit.shield=i_smallshield;
20441
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 32 times.
48 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20442
20443
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(sshieldid != -1)
20444 16 temp_zinit.items[sshieldid] = true;
20445 16 }
20446
20447
3/6
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20448 {
20449 4 temp_zinit.hc=3;
20450 4 temp_zinit.start_heart=3;
20451 4 temp_zinit.cont_heart=3;
20452 4 temp_zinit.max_bombs=8;
20453 4 }
20454
20455
3/6
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20456 {
20457 4 sword_hearts[0]=0;
20458 4 sword_hearts[1]=5;
20459 4 sword_hearts[2]=12;
20460 4 sword_hearts[3]=21;
20461 4 }
20462
20463
3/4
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
128 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20464 {
20465 4 temp_zinit.last_map=0;
20466 4 temp_zinit.last_screen=0;
20467 4 }
20468
20469
3/6
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20470 {
20471 4 temp_zinit.max_magic=0;
20472 4 temp_zinit.magic=0;
20473
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20474 4 }
20475
20476
3/4
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
128 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20477 {
20478
20479
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t x=0; x<4; x++)
20480 {
20481 16 beam_hearts[x]=100;
20482 16 }
20483
20484
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<idBP_MAX; i++)
20485 {
20486
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20487
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 set_qr(qr_LENSHINTS+i,0);
20488 16 }
20489
20490
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
20 for(int32_t x=0; x<4; x++)
20491 {
20492
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20493 16 }
20494
20495
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_qr(qr_HIDECARRIEDITEMS,0);
20496 4 hookshot_links=100;
20497 4 temp_zinit.msg_more_x=224;
20498 4 temp_zinit.msg_more_y=64;
20499 4 }
20500
20501 // Okay, let's put these legacy values into itemsbuf.
20502
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version < 15)
20503
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4096 times.
4112 for(int32_t i=0; i<MAXITEMS; i++)
20504 {
20505
11/11
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 8 taken 3936 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
4096 switch(i)
20506 {
20507 case iFairyStill:
20508 16 itemsbuf[i].misc1 = stationary_fairy_hearts;
20509 16 itemsbuf[i].misc2 = stationary_fairy_magic;
20510 16 itemsbuf[i].misc3 = 0;
20511 16 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20512 16 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20513 16 break;
20514
20515 case iFairyMoving:
20516 16 itemsbuf[i].misc1 = moving_fairy_hearts;
20517 16 itemsbuf[i].misc2 = moving_fairy_magic;
20518 16 itemsbuf[i].misc3 = 50;
20519 16 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20520 16 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20521 16 break;
20522
20523 case iRPotion:
20524 16 itemsbuf[i].misc1 = red_potion_hearts;
20525 16 itemsbuf[i].misc2 = red_potion_magic;
20526 16 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20527 16 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20528 16 break;
20529
20530 case iBPotion:
20531 16 itemsbuf[i].misc1 = blue_potion_hearts;
20532 16 itemsbuf[i].misc2 = blue_potion_magic;
20533 16 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20534 16 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20535 16 break;
20536
20537 case iSword:
20538 16 itemsbuf[i].pickup_hearts = sword_hearts[0];
20539 16 itemsbuf[i].misc1 = beam_hearts[0];
20540 16 itemsbuf[i].misc2 = beam_power[0];
20541 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20542
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20543 16 break;
20544
20545 case iWSword:
20546 16 itemsbuf[i].pickup_hearts = sword_hearts[1];
20547 16 itemsbuf[i].misc1 = beam_hearts[1];
20548 16 itemsbuf[i].misc2 = beam_power[1];
20549
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20550 16 break;
20551
20552 case iMSword:
20553 16 itemsbuf[i].pickup_hearts = sword_hearts[2];
20554 16 itemsbuf[i].misc1 = beam_hearts[2];
20555 16 itemsbuf[i].misc2 = beam_power[2];
20556
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20557 16 break;
20558
20559 case iXSword:
20560 16 itemsbuf[i].pickup_hearts = sword_hearts[3];
20561 16 itemsbuf[i].misc1 = beam_hearts[3];
20562 16 itemsbuf[i].misc2 = beam_power[3];
20563
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20564 16 break;
20565
20566 case iHookshot:
20567 16 itemsbuf[i].misc1 = hookshot_length;
20568 16 itemsbuf[i].misc2 = hookshot_links;
20569 16 break;
20570
20571 case iLongshot:
20572 16 itemsbuf[i].misc1 = longshot_length;
20573 16 itemsbuf[i].misc2 = longshot_links;
20574 16 break;
20575 }
20576 4112 }
20577
20578
3/6
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20579 {
20580 //was new subscreen rule
20581
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.subscreen=get_qr(qr_FREEFORM)?1:0;
20582
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_qr(qr_FREEFORM,0);
20583 4 }
20584
20585
3/4
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
128 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20586 {
20587 4 temp_zinit.start_dmap=0;
20588 4 }
20589
20590
3/6
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20591 {
20592
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
20593 4 }
20594
20595
4/6
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 112 times.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
128 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20596 {
20597 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20598 temp_zinit.max_rupees=999;
20599 //temp_zinit.rupies=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20600 }
20601
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20602 {
20603 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20604 temp_zinit.max_bombs = 8;
20605 }
20606 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20607 //time to ensure that we port all new values properly:
20608
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(Header->zelda_version < 0x250)
20609 {
20610
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 temp_zinit.max_sbombs = temp_zinit.bomb_ratio > 0 ? ( temp_zinit.max_bombs/temp_zinit.bomb_ratio ) : (temp_zinit.max_bombs/4);
20611 16 }
20612
20613
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(s_version > 21)
20614 {
20615
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_getc(&temp_zinit.hp_per_heart,f))
20616 {
20617 return qe_invalid;
20618 }
20619
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_getc(&temp_zinit.magic_per_block,f))
20620 {
20621 return qe_invalid;
20622 }
20623
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20624 {
20625 return qe_invalid;
20626 }
20627
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20628 {
20629 return qe_invalid;
20630 }
20631 35 }
20632 else
20633 {
20634 93 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20635 93 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20636 93 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20637 93 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20638 }
20639
20640
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(s_version > 22)
20641 {
20642
2/2
✓ Branch 0 taken 875 times.
✓ Branch 1 taken 35 times.
910 for(int32_t q = 0; q < 25; ++q)
20643 {
20644
2/4
✓ Branch 0 taken 875 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 875 times.
875 if(!p_igetw(&temp_zinit.scrcnt[q],f))
20645 {
20646 return qe_invalid;
20647 }
20648 875 }
20649
2/2
✓ Branch 0 taken 875 times.
✓ Branch 1 taken 35 times.
910 for(int32_t q = 0; q < 25; ++q)
20650 {
20651
2/4
✓ Branch 0 taken 875 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 875 times.
875 if(!p_igetw(&temp_zinit.scrmaxcnt[q],f))
20652 {
20653 return qe_invalid;
20654 }
20655 875 }
20656 35 }
20657 else
20658 {
20659
2/2
✓ Branch 0 taken 2325 times.
✓ Branch 1 taken 93 times.
2418 for(int32_t q = 0; q < 25; ++q)
20660 {
20661 2325 temp_zinit.scrcnt[q] = 0;
20662 2325 temp_zinit.scrmaxcnt[q] = 0;
20663 2325 }
20664 }
20665
20666
20667
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(s_version > 23)
20668 {
20669
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_getc(&temp_zinit.dither_type,f))
20670 {
20671 return qe_invalid;
20672 }
20673
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_getc(&temp_zinit.dither_arg,f))
20674 {
20675 return qe_invalid;
20676 }
20677
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_getc(&temp_zinit.dither_percent,f))
20678 {
20679 return qe_invalid;
20680 }
20681
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_getc(&temp_zinit.def_lightrad,f))
20682 {
20683 return qe_invalid;
20684 }
20685
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_getc(&temp_zinit.transdark_percent,f))
20686 {
20687 return qe_invalid;
20688 }
20689 35 }
20690 else
20691 {
20692 93 temp_zinit.dither_type = 0;
20693 93 temp_zinit.dither_arg = 0;
20694 93 temp_zinit.dither_percent = 20;
20695 93 temp_zinit.def_lightrad = 24;
20696 93 temp_zinit.transdark_percent = 0;
20697 }
20698
20699
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(s_version > 24)
20700 {
20701
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_getc(&temp_zinit.darkcol,f))
20702 {
20703 return qe_invalid;
20704 }
20705 35 }
20706 else
20707 {
20708 93 temp_zinit.darkcol = BLACK;
20709 }
20710
20711
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(s_version > 25)
20712 {
20713
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_igetl(&temp_zinit.gravity2,f))
20714 {
20715 return qe_invalid;
20716 }
20717
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_igetl(&temp_zinit.swimgravity,f))
20718 {
20719 return qe_invalid;
20720 }
20721 35 }
20722 else
20723 {
20724 93 temp_zinit.gravity2 = temp_zinit.gravity*100;
20725 93 temp_zinit.swimgravity = 5;
20726 }
20727
20728
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(s_version > 26)
20729 {
20730
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20731 {
20732 return qe_invalid;
20733 }
20734
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20735 {
20736 return qe_invalid;
20737 }
20738
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20739 {
20740 return qe_invalid;
20741 }
20742 35 }
20743 else
20744 {
20745 93 temp_zinit.heroSideswimUpStep = 150;
20746 93 temp_zinit.heroSideswimSideStep = 100;
20747 93 temp_zinit.heroSideswimDownStep = 75;
20748 }
20749
20750
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(s_version > 27)
20751 {
20752
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20753 {
20754 return qe_invalid;
20755 }
20756 35 }
20757 else
20758 {
20759 93 temp_zinit.exitWaterJump = 0;
20760 }
20761
20762
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(s_version > 29)
20763 {
20764
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20765 {
20766 return qe_invalid;
20767 }
20768 35 }
20769 else
20770 {
20771 93 temp_zinit.bunny_ltm = 0;
20772 }
20773
20774
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(s_version > 30)
20775 {
20776
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_getc(&temp_zinit.switchhookstyle,f))
20777 {
20778 return qe_invalid;
20779 }
20780 35 }
20781 else
20782 {
20783 93 temp_zinit.switchhookstyle = 1;
20784 }
20785
20786
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(s_version > 31)
20787 {
20788
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_getc(&temp_zinit.magicdrainrate,f))
20789 {
20790 return qe_invalid;
20791 }
20792 35 }
20793 else
20794 {
20795
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 temp_zinit.magicdrainrate = (get_bit(temp_zinit.misc,idM_DOUBLEMAGIC) ? 1 : 2);
20796
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20797 }
20798
20799
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 temp_zinit.clear_genscript();
20800
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 95 times.
128 if(s_version > 32)
20801 {
20802 33 word numgenscript = 0;
20803
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
33 if(!p_igetw(&numgenscript,f))
20804 return qe_invalid;
20805
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if (!(numgenscript >= 0 && numgenscript <= NUMSCRIPTSGENERIC))
20806 return qe_invalid;
20807
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 for(auto q = 1; q < numgenscript; ++q)
20808 {
20809 if(!p_getc(&padding,f))
20810 return qe_invalid;
20811 if(!(padding&2))
20812 continue;
20813 temp_zinit.gen_doscript[q] = padding&1;
20814 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
20815 return qe_invalid;
20816 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
20817 return qe_invalid;
20818 for(auto p = 0; p < 8; ++p)
20819 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
20820 return qe_invalid;
20821 if(!p_igetl(&temp_zinit.gen_dataSize[q],f))
20822 return qe_invalid;
20823 if(!p_getlvec<int32_t>(&temp_zinit.gen_data[q],f))
20824 return qe_invalid;
20825 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
20826 return qe_invalid;
20827 }
20828 33 }
20829
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 98 times.
128 if(s_version > 33)
20830 {
20831
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20832 return qe_invalid;
20833
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.hero_swim_div,f))
20834 return qe_invalid;
20835 30 }
20836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(s_version > 34)
20837 {
20838 uint32_t num_used_mapscr_data;
20839 if(!p_igetl(&num_used_mapscr_data,f))
20840 return qe_invalid;
20841 for(uint32_t q = 0; q < num_used_mapscr_data; ++q)
20842 {
20843 if(!p_igetl(&temp_zinit.vecs.screen_dataSize[q],f))
20844 return qe_invalid;
20845 if(temp_zinit.vecs.screen_dataSize[q])
20846 if(!p_getlvec(&temp_zinit.vecs.screen_data[q],f))
20847 return qe_invalid;
20848 }
20849 }
20850
20851
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if (should_skip)
20852 return 0;
20853
20854
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(loading_tileset_flags & TILESET_CLEARMAPS)
20855 {
20856 temp_zinit.last_map = 0;
20857 temp_zinit.last_screen = 0;
20858 }
20859
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 zinit = temp_zinit;
20860
20861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(zinit.heroAnimationStyle==las_zelda3slow)
20862 {
20863 hero_animation_speed=2;
20864 }
20865 else
20866 {
20867 128 hero_animation_speed=1;
20868 }
20869
20870 128 return 0;
20871 440 }
20872
20873 /*
20874 void setupitemdropsets()
20875 {
20876 for(int32_t i=0; i<isMAX; i++)
20877 {
20878 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
20879 }
20880 }
20881 */
20882
20883 116 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build)
20884 {
20885
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 4 times.
116 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_itemdropsets);
20886
20887 116 build=build; // here to prevent compiler warnings
20888 dword dummy_dword;
20889 116 word item_drop_sets_to_read=0;
20890 item_drop_object tempitemdrop;
20891 116 word s_version=0, s_cversion=0;
20892
20893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if (!should_skip)
20894
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 116 times.
29812 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
20895 {
20896 29696 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
20897 29812 }
20898
20899
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 4 times.
116 if(version > 0x192)
20900 {
20901 112 item_drop_sets_to_read=0;
20902
20903 //section version info
20904
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetw(&s_version,f))
20905 {
20906 return qe_invalid;
20907 }
20908
20909 112 FFCore.quest_format[vItemDropsets] = s_version;
20910
20911 //al_trace("Item drop sets version %d\n", s_version);
20912
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetw(&s_cversion,f))
20913 {
20914 return qe_invalid;
20915 }
20916
20917 //section size
20918
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetl(&dummy_dword,f))
20919 {
20920 return qe_invalid;
20921 }
20922
20923 //finally... section data
20924
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetw(&item_drop_sets_to_read,f))
20925 {
20926 return qe_invalid;
20927 }
20928
20929
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if (!(item_drop_sets_to_read >= 0 && item_drop_sets_to_read <= MAXITEMDROPSETS))
20930 {
20931 return qe_invalid;
20932 }
20933 112 }
20934 else
20935 {
20936 4 init_item_drop_sets();
20937 }
20938
20939
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 112 times.
116 if(s_version>=1)
20940 {
20941
2/2
✓ Branch 0 taken 2056 times.
✓ Branch 1 taken 112 times.
2168 for(int32_t i=0; i<item_drop_sets_to_read; i++)
20942 {
20943
1/2
✓ Branch 0 taken 2056 times.
✗ Branch 1 not taken.
2056 if(!pfread(tempitemdrop.name,sizeof(tempitemdrop.name),f))
20944 {
20945 return qe_invalid;
20946 }
20947
20948
2/2
✓ Branch 0 taken 20560 times.
✓ Branch 1 taken 2056 times.
22616 for(int32_t j=0; j<10; ++j)
20949 {
20950
1/2
✓ Branch 0 taken 20560 times.
✗ Branch 1 not taken.
20560 if(!p_igetw(&tempitemdrop.item[j],f))
20951 {
20952 return qe_invalid;
20953 }
20954 20560 }
20955
20956
2/2
✓ Branch 0 taken 22616 times.
✓ Branch 1 taken 2056 times.
24672 for(int32_t j=0; j<11; ++j)
20957 {
20958
1/2
✓ Branch 0 taken 22616 times.
✗ Branch 1 not taken.
22616 if(!p_igetw(&tempitemdrop.chance[j],f))
20959 {
20960 return qe_invalid;
20961 }
20962 22616 }
20963
20964 // Dec 2008: Addition of the 'Tall Grass' set, #12,
20965 // overrides the quest's set #12.
20966
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2056 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2056 if(s_version<2 && i==12)
20967 continue;
20968
20969 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
20970
1/4
✓ Branch 0 taken 2056 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2056 if(s_version<2) for(int32_t j=0; j<10; ++j)
20971 {
20972 int32_t it = tempitemdrop.item[j];
20973
20974 if((itemsbuf[it].family == itype_rupee
20975 && ((itemsbuf[it].amount)&0xFFF) == 10)
20976 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
20977 {
20978 tempitemdrop.chance[j+1]=0;
20979 }
20980 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
20981 {
20982 tempitemdrop.chance[j+1]=0;
20983 }
20984
20985 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
20986 if(itemsbuf[it].family == itype_misc)
20987 {
20988 // If a non-gameplay item was selected, then item drop was aborted.
20989 // Reflect this by increasing the 'Nothing' chance accordingly.
20990 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
20991 tempitemdrop.chance[j+1]=0;
20992 }
20993 }
20994
20995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2056 times.
2056 if (!should_skip)
20996 2056 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
20997 2056 }
20998 112 }
20999
21000 116 return 0;
21001 116 }
21002
21003 112 int32_t readfavorites(PACKFILE *f, int32_t, word)
21004 {
21005
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_favorites);
21006
21007 int32_t temp_num;
21008 dword dummy_dword;
21009 word num_favorite_combos;
21010 word num_favorite_combo_aliases;
21011 112 word s_version=0, s_cversion=0;
21012
21013 //section version info
21014
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetw(&s_version,f))
21015 {
21016 return qe_invalid;
21017 }
21018
21019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if (!should_skip)
21020 112 FFCore.quest_format[vFavourites] = s_version;
21021
21022
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetw(&s_cversion,f))
21023 {
21024 return qe_invalid;
21025 }
21026
21027 //section size
21028
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetl(&dummy_dword,f))
21029 {
21030 return qe_invalid;
21031 }
21032
21033 112 word per_row = FAVORITECOMBO_PER_ROW;
21034 112 word per_page = FAVORITECOMBO_PER_PAGE;
21035
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 30 times.
112 if(s_version >= 3)
21036
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetw(&per_row,f))
21037 return qe_invalid;
21038
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 8 times.
112 if(s_version >= 4)
21039
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetw(&per_page,f))
21040 return qe_invalid;
21041 //finally... section data
21042
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetw(&num_favorite_combos,f))
21043 {
21044 return qe_invalid;
21045 }
21046
21047 //Hack; port old favorite combos
21048
3/4
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 82 times.
112 if(s_version < 3 && num_favorite_combos == 100)
21049 82 per_row = 13;
21050
21051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if (!should_skip)
21052
2/2
✓ Branch 0 taken 141120 times.
✓ Branch 1 taken 112 times.
141232 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21053 141232 favorite_combos[q] = -1;
21054 112 byte favtype = 0;
21055
2/2
✓ Branch 0 taken 9366 times.
✓ Branch 1 taken 112 times.
9478 for(int32_t i=0; i<num_favorite_combos; i++)
21056 {
21057
2/2
✓ Branch 0 taken 1144 times.
✓ Branch 1 taken 8222 times.
9366 if (s_version >= 4)
21058 {
21059
1/2
✓ Branch 0 taken 1144 times.
✗ Branch 1 not taken.
1144 if (!p_getc(&favtype, f))
21060 {
21061 return qe_invalid;
21062 }
21063 1144 }
21064 else
21065 8222 favtype = 0;
21066
1/2
✓ Branch 0 taken 9366 times.
✗ Branch 1 not taken.
9366 if(!p_igetl(&temp_num,f))
21067 {
21068 return qe_invalid;
21069 }
21070
21071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9366 times.
9366 if (should_skip)
21072 continue;
21073
21074
2/2
✓ Branch 0 taken 1144 times.
✓ Branch 1 taken 8222 times.
9366 if(per_row == FAVORITECOMBO_PER_ROW)
21075 {
21076 1144 favorite_combos[i] = temp_num;
21077 1144 favorite_combo_modes[i] = favtype;
21078 1144 }
21079 else
21080 {
21081 8222 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21082 8222 favorite_combos[new_i]=temp_num;
21083 8222 favorite_combo_modes[new_i] = favtype;
21084 }
21085 9366 }
21086
21087 // Discard the separate favorite aliases list from previous versions
21088
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 104 times.
112 if(s_version<4)
21089 {
21090
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if (!p_igetw(&num_favorite_combo_aliases, f))
21091 {
21092 return qe_invalid;
21093 }
21094
21095
2/2
✓ Branch 0 taken 8200 times.
✓ Branch 1 taken 104 times.
8304 for (int32_t i = 0; i < num_favorite_combo_aliases; i++)
21096 {
21097
1/2
✓ Branch 0 taken 8200 times.
✗ Branch 1 not taken.
8200 if (!p_igetl(&temp_num, f))
21098 {
21099 return qe_invalid;
21100 }
21101 8200 }
21102 104 }
21103
21104 112 word max_combo_cols = 0;
21105 112 word max_mappages = 0;
21106
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 30 times.
112 if(s_version >= 2)
21107 {
21108
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetw(&max_combo_cols,f))
21109 return qe_invalid;
21110 30 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21111
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int q = 0; q < max_combo_cols; ++q)
21112 {
21113
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tmp,f))
21114 return qe_invalid;
21115
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tmp2,f))
21116 return qe_invalid;
21117
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tmp3,f))
21118 return qe_invalid;
21119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(q < MAX_COMBO_COLS)
21120 {
21121 120 First[q] = tmp;
21122 120 combo_alistpos[q] = tmp2;
21123 120 combo_pool_listpos[q] = tmp3;
21124 120 }
21125 120 }
21126
21127
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetw(&max_mappages,f))
21128 return qe_invalid;
21129
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 30 times.
300 for(int q = 0; q < max_mappages; ++q)
21130 {
21131
1/2
✓ Branch 0 taken 270 times.
✗ Branch 1 not taken.
270 if(!p_igetl(&tmp,f))
21132 return qe_invalid;
21133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 270 times.
270 if(!p_igetl(&tmp2,f))
21134 return qe_invalid;
21135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 270 times.
270 if(q < MAX_MAPPAGE_BTNS)
21136 {
21137 270 map_page[q].map = tmp;
21138 270 map_page[q].screen = tmp2;
21139 270 }
21140 270 }
21141 30 }
21142
21143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if (should_skip)
21144 return 0;
21145
21146
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 112 times.
440 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21147 {
21148 328 First[q] = 0;
21149 328 combo_alistpos[q] = 0;
21150 328 combo_pool_listpos[q] = 0;
21151 328 }
21152
2/2
✓ Branch 0 taken 738 times.
✓ Branch 1 taken 112 times.
850 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21153 {
21154 738 map_page[q].map = 0;
21155 738 map_page[q].screen = 0;
21156 738 }
21157
21158 112 return 0;
21159 112 }
21160
21161 /*
21162 switch (ret) {
21163 case 0:
21164 break;
21165
21166 case qe_invalid:
21167 goto invalid;
21168 break;
21169 default:
21170 pack_fclose(f);
21171 if(!oldquest)
21172 delete_file(tmpfilename);
21173 return ret;
21174 break;
21175 }
21176 */
21177
21178 const char *skip_text[skip_max]=
21179 {
21180 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21181 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21182 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21183 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21184 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21185 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21186 "skip_favorites"
21187 };
21188
21189
21190 void port250QuestRules(){
21191
21192 portCandleRules(); //Candle
21193 portBombRules();
21194
21195 }
21196
21197 void portCandleRules()
21198 {
21199 bool hurtshero = get_qr(qr_FIREPROOFHERO);
21200 //itemdata itemsbuf;
21201 for ( int32_t q = 0; q < MAXITEMS; q++ )
21202 {
21203 if ( itemsbuf[q].family == itype_candle )
21204 {
21205 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21206 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21207 }
21208 }
21209 }
21210
21211 void portBombRules()
21212 {
21213 bool hurtshero = get_qr(qr_OUCHBOMBS);
21214 //itemdata itemsbuf;
21215 for ( int32_t q = 0; q < MAXITEMS; q++ )
21216 {
21217 if ( itemsbuf[q].family == itype_bomb )
21218 {
21219 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21220 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21221 }
21222 }
21223 }
21224
21225 2936 static int section_id_to_enum(int id)
21226 {
21227
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 128 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 128 times.
✓ Branch 6 taken 112 times.
✓ Branch 7 taken 128 times.
✓ Branch 8 taken 128 times.
✓ Branch 9 taken 128 times.
✓ Branch 10 taken 128 times.
✓ Branch 11 taken 128 times.
✓ Branch 12 taken 128 times.
✓ Branch 13 taken 112 times.
✓ Branch 14 taken 112 times.
✓ Branch 15 taken 128 times.
✓ Branch 16 taken 128 times.
✓ Branch 17 taken 116 times.
✓ Branch 18 taken 112 times.
✓ Branch 19 taken 112 times.
✓ Branch 20 taken 112 times.
✓ Branch 21 taken 128 times.
✓ Branch 22 taken 128 times.
✓ Branch 23 taken 116 times.
✓ Branch 24 taken 112 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
2936 switch (id)
21228 {
21229 case ID_HEADER: return skip_header;
21230 128 case ID_RULES: return skip_rules;
21231 128 case ID_STRINGS: return skip_strings;
21232 128 case ID_MISC: return skip_misc;
21233 128 case ID_TILES: return skip_tiles;
21234 128 case ID_COMBOS: return skip_combos;
21235 112 case ID_COMBOALIASES: return skip_comboaliases;
21236 128 case ID_CSETS: return skip_csets;
21237 128 case ID_MAPS: return skip_maps;
21238 128 case ID_DMAPS: return skip_dmaps;
21239 128 case ID_DOORS: return skip_doors;
21240 128 case ID_ITEMS: return skip_items;
21241 128 case ID_WEAPONS: return skip_weapons;
21242 112 case ID_COLORS: return skip_colors;
21243 112 case ID_ICONS: return skip_icons;
21244 128 case ID_INITDATA: return skip_initdata;
21245 128 case ID_GUYS: return skip_guys;
21246 116 case ID_HEROSPRITES: return skip_herosprites;
21247 112 case ID_SUBSCREEN: return skip_subscreens;
21248 112 case ID_FFSCRIPT: return skip_ffscript;
21249 112 case ID_SFX: return skip_sfx;
21250 128 case ID_MIDIS: return skip_midis;
21251 128 case ID_CHEATS: return skip_cheats;
21252 116 case ID_ITEMDROPSETS: return skip_itemdropsets;
21253 112 case ID_FAVORITES: return skip_favorites;
21254 case ID_ZINFO: return skip_zinfo;
21255 }
21256
21257 return -1;
21258 2936 }
21259
21260 2868 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
21261 {
21262 2868 int section_enum = section_id_to_enum(section_id);
21263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2868 times.
2868 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2868 times.
2868 if (skip)
21265 {
21266 word s_version;
21267 if (!p_igetw(&s_version,f))
21268 {
21269 return qe_invalid;
21270 }
21271
21272 word c_version;
21273 if (!p_igetw(&c_version,f))
21274 {
21275 return qe_invalid;
21276 }
21277
21278 if (section_id == ID_RULES && s_version > 16)
21279 {
21280 dword dummy;
21281 if (!p_igetl(&dummy,f))
21282 {
21283 return qe_invalid;
21284 }
21285 }
21286
21287 if (section_id == ID_FFSCRIPT && s_version >= 18)
21288 {
21289 word dummy;
21290 if (!p_igetw(&dummy,f))
21291 {
21292 return qe_invalid;
21293 }
21294 }
21295
21296 dword section_length;
21297 if (!p_igetl(&section_length,f))
21298 {
21299 return qe_invalid;
21300 }
21301
21302 if (pack_fseek(f, section_length))
21303 {
21304 return qe_invalid;
21305 }
21306
21307 if (!pack_feof(f))
21308 {
21309 if (!p_mgetl(&section_id,f))
21310 {
21311 return qe_invalid;
21312 }
21313 }
21314
21315 return qe_cancel;
21316 }
21317
21318 2868 return qe_OK;
21319 2868 }
21320
21321 //Internal function for loadquest wrapper
21322 128 int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata)
21323 {
21324 128 DMapEditorLastMaptileUsed = 0;
21325 128 combosread=false;
21326 128 mapsread=false;
21327 128 fixffcs=false;
21328
21329 128 bool do_clear_scripts = !get_bit(skip_flags,skip_ffscript);
21330
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
21331 {
21332 set_bit(skip_flags, skip_ffscript, 1);
21333 setZScriptVersion(V_FFSCRIPT);
21334 FFCore.quest_format[vFFScript] = V_FFSCRIPT;
21335 FFCore.quest_format[vLastCompile] = V_FFSCRIPT;
21336 do_clear_scripts = true;
21337 }
21338
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(loading_tileset_flags & TILESET_CLEARMAPS)
21339 {
21340 set_bit(skip_flags, skip_maps, 1);
21341 }
21342
21343 // show_progress=true;
21344 char tmpfilename[L_tmpnam];
21345 128 temp_name(tmpfilename);
21346 // char percent_done[30];
21347 128 bool catchup=false;
21348 byte tempbyte;
21349 128 word old_map_count=map_count;
21350
21351 128 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21352 128 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21353 128 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21354
21355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(get_bit(skip_flags, skip_rules))
21356 {
21357 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21358 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21359 }
21360
21361 128 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21362 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21363
21364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(get_bit(skip_flags, skip_midis))
21365 {
21366 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21367 }
21368
21369
21370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(do_clear_scripts)
21371 {
21372 128 zScript.clear();
21373 128 globalmap.clear();
21374 128 genericmap.clear();
21375 128 ffcmap.clear();
21376 128 itemmap.clear();
21377 128 npcmap.clear();
21378 128 ewpnmap.clear();
21379 128 lwpnmap.clear();
21380 128 playermap.clear();
21381 128 dmapmap.clear();
21382 128 screenmap.clear();
21383 128 itemspritemap.clear();
21384 128 comboscriptmap.clear();
21385 128 subscreenmap.clear();
21386
21387
2/2
✓ Branch 0 taken 65408 times.
✓ Branch 1 taken 128 times.
65536 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21388 {
21389 65408 ffcmap[i].clear();
21390 65408 }
21391
21392 128 globalmap[0].slotname = "Slot 1:";
21393 128 globalmap[0].scriptname = "~Init";
21394 128 globalmap[0].update();
21395
21396
2/2
✓ Branch 0 taken 896 times.
✓ Branch 1 taken 128 times.
1024 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21397 {
21398 896 globalmap[i].clear();
21399 896 }
21400
21401
2/2
✓ Branch 0 taken 32640 times.
✓ Branch 1 taken 128 times.
32768 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21402 {
21403 32640 itemmap[i].clear();
21404 32640 }
21405
21406 //new script types -- prevent carrying over to a quest that you load after reading them
21407 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21408
2/2
✓ Branch 0 taken 32640 times.
✓ Branch 1 taken 128 times.
32768 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21409 {
21410 32640 npcmap[i].clear();
21411 32640 }
21412
2/2
✓ Branch 0 taken 32640 times.
✓ Branch 1 taken 128 times.
32768 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21413 {
21414 32640 lwpnmap[i].clear();
21415 32640 }
21416
2/2
✓ Branch 0 taken 32640 times.
✓ Branch 1 taken 128 times.
32768 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21417 {
21418 32640 ewpnmap[i].clear();
21419 32640 }
21420
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 128 times.
640 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21421 {
21422 512 playermap[i].clear();
21423 512 }
21424
2/2
✓ Branch 0 taken 32640 times.
✓ Branch 1 taken 128 times.
32768 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21425 {
21426 32640 dmapmap[i].clear();
21427 32640 }
21428
2/2
✓ Branch 0 taken 32640 times.
✓ Branch 1 taken 128 times.
32768 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21429 {
21430 32640 screenmap[i].clear();
21431 32640 }
21432
2/2
✓ Branch 0 taken 32640 times.
✓ Branch 1 taken 128 times.
32768 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21433 {
21434 32640 itemspritemap[i].clear();
21435 32640 }
21436
2/2
✓ Branch 0 taken 65408 times.
✓ Branch 1 taken 128 times.
65536 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21437 {
21438 65408 comboscriptmap[i].clear();
21439 65408 }
21440
2/2
✓ Branch 0 taken 65408 times.
✓ Branch 1 taken 128 times.
65536 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21441 {
21442 65408 genericmap[i].clear();
21443 65408 }
21444
2/2
✓ Branch 0 taken 32640 times.
✓ Branch 1 taken 128 times.
32768 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN-1; i++)
21445 {
21446 32640 subscreenmap[i].clear();
21447 32640 }
21448
21449 128 reset_scripts();
21450 128 }
21451
21452 zquestheader tempheader;
21453 128 memset(&tempheader, 0, sizeof(zquestheader));
21454 128 zinfo tempzi;
21455 128 tempzi.clear();
21456 128 load_tmp_zi = &tempzi;
21457
21458 // oldquest flag is set when an unencrypted qst file is suspected.
21459 128 bool oldquest = false;
21460 128 int32_t open_error=0;
21461 128 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21462
21463
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if (!f)
21464 {
21465 ASSERT(open_error != 0);
21466 return open_error;
21467 }
21468 char zinfofilename[2048];
21469 128 replace_extension(zinfofilename, filename, "zinfo", 2047);
21470 128 int32_t ret=0;
21471
21472 //header
21473 128 box_out("Reading Header...");
21474 128 ret=readheader(f, &tempheader, printmetadata);
21475
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
128 checkstatus(ret);
21476 128 box_out("okay.");
21477 128 box_eol();
21478
21479
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 35 times.
128 if(read_zinfo)
21480 {
21481 35 box_out("Reading ZInfo - ");
21482
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 34 times.
35 box_out(read_ext_zinfo ? "External..." : "Internal...");
21483
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 34 times.
35 if(read_ext_zinfo)
21484 {
21485 1 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21486 1 ret=readzinfo(inf, tempzi, tempheader);
21487
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(inf) pack_fclose(inf);
21488
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 checkstatus(ret);
21489 1 }
21490 else
21491 {
21492 34 ret=readzinfo(f, tempzi, tempheader);
21493
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
34 checkstatus(ret);
21494 }
21495 35 box_out("okay.");
21496 35 box_eol();
21497 35 }
21498
21499
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if(tempheader.zelda_version>=0x193)
21500 {
21501 dword section_id;
21502
21503 //section id
21504
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_mgetl(&section_id,f))
21505 {
21506 return qe_invalid;
21507 }
21508
21509 124 std::set<dword> seen_sections;
21510
21511
3/4
✓ Branch 0 taken 2992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2868 times.
✓ Branch 3 taken 124 times.
2992 while(!pack_feof(f))
21512 {
21513
2/4
✓ Branch 0 taken 2868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2868 times.
✗ Branch 3 not taken.
2868 if (seen_sections.contains(section_id))
21514 return qe_invalid;
21515
1/2
✓ Branch 0 taken 2868 times.
✗ Branch 1 not taken.
2868 seen_sections.insert(section_id);
21516
21517
2/4
✓ Branch 0 taken 2868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2868 times.
✗ Branch 3 not taken.
2868 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
21518 {
21519 if (retval == qe_cancel)
21520 continue;
21521 checkstatus(retval);
21522 }
21523
21524
24/25
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 124 times.
✓ Branch 2 taken 124 times.
✓ Branch 3 taken 124 times.
✓ Branch 4 taken 124 times.
✓ Branch 5 taken 112 times.
✓ Branch 6 taken 124 times.
✓ Branch 7 taken 124 times.
✓ Branch 8 taken 124 times.
✓ Branch 9 taken 124 times.
✓ Branch 10 taken 124 times.
✓ Branch 11 taken 124 times.
✓ Branch 12 taken 112 times.
✓ Branch 13 taken 112 times.
✓ Branch 14 taken 124 times.
✓ Branch 15 taken 124 times.
✓ Branch 16 taken 112 times.
✓ Branch 17 taken 112 times.
✓ Branch 18 taken 112 times.
✓ Branch 19 taken 112 times.
✓ Branch 20 taken 124 times.
✓ Branch 21 taken 124 times.
✓ Branch 22 taken 112 times.
✓ Branch 23 taken 112 times.
✗ Branch 24 not taken.
2868 switch(section_id)
21525 {
21526 case ID_RULES:
21527
21528 //rules
21529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21530 {
21531 box_out("found.");
21532 box_eol();
21533 catchup=false;
21534 }
21535
21536
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Rules...");
21537
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readrules(f, &tempheader);
21538
1/9
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21539
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21540
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21541 124 break;
21542
21543 case ID_STRINGS:
21544
21545 //strings
21546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21547 {
21548 box_out("found.");
21549 box_eol();
21550 catchup=false;
21551 }
21552
21553
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Strings...");
21554
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readstrings(f, &tempheader);
21555
1/9
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21556
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21557
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21558 124 break;
21559
21560 case ID_MISC:
21561
21562 //misc data
21563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21564 {
21565 box_out("found.");
21566 box_eol();
21567 catchup=false;
21568 }
21569
21570
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Misc. Data...");
21571
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readmisc(f, &tempheader, Misc);
21572
1/9
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21573
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21574
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21575 124 break;
21576
21577 case ID_TILES:
21578
21579 //tiles
21580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21581 {
21582 box_out("found.");
21583 box_eol();
21584 catchup=false;
21585 }
21586
21587
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Tiles...");
21588
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
21589
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21590
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21591
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21592 124 break;
21593
21594 case ID_COMBOS:
21595
21596 //combos
21597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21598 {
21599 box_out("found.");
21600 box_eol();
21601 catchup=false;
21602 }
21603
21604
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Combos...");
21605
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
21606 124 combosread=true;
21607
1/9
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21608
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21609
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21610 124 break;
21611
21612 case ID_COMBOALIASES:
21613
21614 //combo aliases
21615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(catchup)
21616 {
21617 box_out("found.");
21618 box_eol();
21619 catchup=false;
21620 }
21621
21622
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("Reading Combo Aliases...");
21623
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
21624
1/9
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
112 checkstatus(ret);
21625
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("okay.");
21626
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_eol();
21627 112 break;
21628
21629 case ID_CSETS:
21630
21631 //color data
21632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21633 {
21634 box_out("found.");
21635 box_eol();
21636 catchup=false;
21637 }
21638
21639
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Color Data...");
21640
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
21641
1/9
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21642
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21643
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21644 124 break;
21645
21646 case ID_MAPS:
21647
21648 //maps
21649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21650 {
21651 box_out("found.");
21652 box_eol();
21653 catchup=false;
21654 }
21655
21656
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Maps...");
21657
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readmaps(f, &tempheader);
21658 124 mapsread=true;
21659
1/9
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21660
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21661
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21662 124 break;
21663
21664 case ID_DMAPS:
21665
21666 //dmaps
21667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21668 {
21669 box_out("found.");
21670 box_eol();
21671 catchup=false;
21672 }
21673
21674
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading DMaps...");
21675
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
21676
1/9
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21677
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21678
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21679 124 break;
21680
21681 case ID_DOORS:
21682
21683 //door combo sets
21684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21685 {
21686 box_out("found.");
21687 box_eol();
21688 catchup=false;
21689 }
21690
21691
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Doors...");
21692
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readdoorcombosets(f, &tempheader);
21693
1/9
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21694
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21695
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21696 124 break;
21697
21698 case ID_ITEMS:
21699
21700 //items
21701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21702 {
21703 box_out("found.");
21704 box_eol();
21705 catchup=false;
21706 }
21707
21708
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Items...");
21709
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readitems(f, tempheader.zelda_version, tempheader.build);
21710
1/9
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21711
21712
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21713
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21714 124 break;
21715
21716 case ID_WEAPONS:
21717
21718 //weapons
21719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21720 {
21721 box_out("found.");
21722 box_eol();
21723 catchup=false;
21724 }
21725
21726
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Weapons...");
21727
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readweapons(f, &tempheader);
21728
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21729
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21730
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21731 124 break;
21732
21733 case ID_COLORS:
21734
21735 //misc. colors
21736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(catchup)
21737 {
21738 box_out("found.");
21739 box_eol();
21740 catchup=false;
21741 }
21742
21743
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("Reading Misc. Colors...");
21744
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 ret=readmisccolors(f, &tempheader, Misc);
21745
1/9
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
112 checkstatus(ret);
21746
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("okay.");
21747
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_eol();
21748 112 break;
21749
21750 case ID_ICONS:
21751
21752 //game icons
21753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(catchup)
21754 {
21755 box_out("found.");
21756 box_eol();
21757 catchup=false;
21758 }
21759
21760
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("Reading Game Icons...");
21761
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 ret=readgameicons(f, &tempheader, Misc);
21762
1/9
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
112 checkstatus(ret);
21763
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("okay.");
21764
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_eol();
21765 112 break;
21766
21767 case ID_INITDATA:
21768
21769 //initialization data
21770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21771 {
21772 box_out("found.");
21773 box_eol();
21774 catchup=false;
21775 }
21776
21777
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Init. Data...");
21778
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readinitdata(f, &tempheader);
21779
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21780
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21781
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21782
21783
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
124 if(!get_bit(skip_flags, skip_subscreens))
21784 {
21785
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 97 times.
124 if(zinit.subscreen!=ssdtMAX) //not using custom subscreens
21786 {
21787
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 setupsubscreens();
21788
21789
2/2
✓ Branch 0 taken 13824 times.
✓ Branch 1 taken 27 times.
13851 for(int32_t i=0; i<MAXDMAPS; ++i)
21790 {
21791 13824 int32_t type=DMaps[i].type&dmfTYPE;
21792
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 13617 times.
13824 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21793
1/2
✓ Branch 0 taken 13824 times.
✗ Branch 1 not taken.
13824 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
21794 13824 }
21795 27 }
21796 124 }
21797
21798
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
124 if(!get_bit(skip_flags, skip_sfx))
21799 {
21800 124 setupsfx();
21801 124 }
21802
21803
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!get_bit(skip_flags, skip_itemdropsets))
21804 {
21805
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 init_item_drop_sets();
21806 124 }
21807
21808
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
124 if(!get_bit(skip_flags, skip_favorites))
21809 {
21810 124 init_favorites();
21811 124 }
21812
21813 124 break;
21814
21815 case ID_GUYS:
21816
21817 //guys
21818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21819 {
21820 box_out("found.");
21821 box_eol();
21822 catchup=false;
21823 }
21824
21825
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Custom Guy Data...");
21826
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readguys(f, &tempheader);
21827
1/9
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21828
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21829
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21830 124 break;
21831
21832 case ID_HEROSPRITES:
21833
21834 //player sprites
21835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(catchup)
21836 {
21837 box_out("found.");
21838 box_eol();
21839 catchup=false;
21840 }
21841
21842
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("Reading Custom Player Sprite Data...");
21843
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 ret=readherosprites(f, &tempheader);
21844
1/9
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
112 checkstatus(ret);
21845
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("okay.");
21846
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_eol();
21847 112 break;
21848
21849 case ID_SUBSCREEN:
21850
21851 //custom subscreens
21852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(catchup)
21853 {
21854 box_out("found.");
21855 box_eol();
21856 catchup=false;
21857 }
21858
21859
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("Reading Custom Subscreen Data...");
21860
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 ret=readsubscreens(f);
21861
1/9
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
112 checkstatus(ret);
21862
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("okay.");
21863
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_eol();
21864 112 break;
21865
21866 case ID_FFSCRIPT:
21867
21868 //Freeform combo scripts
21869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(catchup)
21870 {
21871 box_out("found.");
21872 box_eol();
21873 catchup=false;
21874 }
21875
21876
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("Reading FF Script Data...");
21877
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 ret=readffscript(f, &tempheader);
21878
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
112 checkstatus(ret);
21879
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("okay.");
21880
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_eol();
21881 112 break;
21882
21883 case ID_SFX:
21884
21885 //SFX data
21886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(catchup)
21887 {
21888 box_out("found.");
21889 box_eol();
21890 catchup=false;
21891 }
21892
21893
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("Reading SFX Data...");
21894
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 ret=readsfx(f, &tempheader);
21895
1/9
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
112 checkstatus(ret);
21896
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("okay.");
21897
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_eol();
21898 112 break;
21899
21900 case ID_MIDIS:
21901
21902 //midis
21903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21904 {
21905 box_out("found.");
21906 box_eol();
21907 catchup=false;
21908 }
21909
21910
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Tunes...");
21911
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readtunes(f, &tempheader, tunes);
21912
1/9
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21913
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21914
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21915 124 break;
21916
21917 case ID_CHEATS:
21918
21919 //cheat codes
21920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21921 {
21922 box_out("found.");
21923 box_eol();
21924 catchup=false;
21925 }
21926
21927
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Cheat Codes...");
21928
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readcheatcodes(f, &tempheader);
21929
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21930
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21931
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21932 124 break;
21933
21934 case ID_ITEMDROPSETS:
21935
21936 //item drop sets
21937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(catchup)
21938 {
21939 box_out("found.");
21940 box_eol();
21941 catchup=false;
21942 }
21943
21944
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("Reading Item Drop Sets...");
21945
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build);
21946
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
112 checkstatus(ret);
21947
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("okay.");
21948
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_eol();
21949 112 break;
21950
21951 case ID_FAVORITES:
21952
21953 //favorite combos and combo aliases
21954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(catchup)
21955 {
21956 box_out("found.");
21957 box_eol();
21958 catchup=false;
21959 }
21960
21961
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("Reading Favorite Combos...");
21962
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 ret=readfavorites(f, tempheader.zelda_version, tempheader.build);
21963
1/9
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
112 checkstatus(ret);
21964
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("okay.");
21965
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_eol();
21966 112 break;
21967
21968 default:
21969 if(!catchup)
21970 {
21971 box_out("Bad token! Searching...");
21972 box_eol();
21973 }
21974
21975 catchup=true;
21976 break;
21977 }
21978
21979
21980
1/2
✓ Branch 0 taken 2868 times.
✗ Branch 1 not taken.
2868 if(catchup)
21981 {
21982 //section id
21983 section_id=(section_id<<8);
21984
21985 if(!p_getc(&tempbyte,f))
21986 {
21987 return qe_invalid;
21988 }
21989
21990 section_id+=tempbyte;
21991 }
21992
21993 else
21994 {
21995 //section id
21996
3/4
✓ Branch 0 taken 2868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2744 times.
✓ Branch 3 taken 124 times.
2868 if(!pack_feof(f))
21997 {
21998
2/4
✓ Branch 0 taken 2744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2744 times.
✗ Branch 3 not taken.
2744 if(!p_mgetl(&section_id,f))
21999 {
22000 return qe_invalid;
22001 }
22002 2744 }
22003 }
22004 }
22005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 }
22006 else
22007 {
22008
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
22009
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
22010
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
22011
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
22012
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
22013
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
22014
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
22015
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
22016
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
22017
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
22018
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
22019
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
22020
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
22021
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Tunes", ID_MIDIS, [&](){ return readtunes(f, &tempheader, tunes); }},
22022
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
22023
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
22024
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Custom Player Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1, 0); }},
22025
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1, 0); }},
22026 };
22027
22028 4 legacy_skip_flags = skip_flags;
22029
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 68 times.
208 for (auto& [desc, section_id, fn] : hardcoded_sections)
22030 {
22031
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 int section_enum = section_id_to_enum(section_id);
22032
2/4
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
68 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
22033
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 if (skip)
22034 {
22035 // Nothing to read.
22036 if (section_id == ID_RULES)
22037 continue;
22038 if (section_id == ID_GUYS)
22039 continue;
22040
22041 // Haven't looked at how to skip these, because we don't need to currently: the only
22042 // usage of skip_flags currently is all off except: header and tiles (see `load_imagebuf`).
22043 if (section_id == ID_MIDIS)
22044 continue;
22045 if (section_id == ID_CHEATS)
22046 continue;
22047 if (section_id == ID_INITDATA)
22048 continue;
22049 if (section_id == ID_HEROSPRITES)
22050 continue;
22051 if (section_id == ID_ITEMDROPSETS)
22052 continue;
22053 }
22054
22055 // Would be nice, but old sections mostly did not save section sizes. We could advance by
22056 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
22057 // read all the sections even if requested to skip some.
22058 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22059 // {
22060 // if (retval == qe_cancel)
22061 // continue;
22062 // checkstatus(retval);
22063 // }
22064
22065
3/6
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 68 times.
✗ Branch 5 not taken.
136 box_out(fmt::format("Reading {}...", desc).c_str());
22066
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 ret = fn();
22067
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
68 checkstatus(ret);
22068
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 box_out("okay.");
22069
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 box_eol();
22070 }
22071 4 legacy_skip_flags = nullptr;
22072
22073
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(!get_bit(skip_flags, skip_subscreens))
22074 {
22075
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 setupsubscreens();
22076
22077
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t i=0; i<MAXDMAPS; ++i)
22078 {
22079 2048 int32_t type=DMaps[i].type&dmfTYPE;
22080
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2036 times.
2048 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22081
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22082 2048 }
22083 4 }
22084
22085
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_out("Setting Up Default Sound Effects...");
22086
22087
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(!get_bit(skip_flags, skip_sfx))
22088 4 setupsfx();
22089
22090
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(!get_bit(skip_flags, skip_favorites))
22091 4 init_favorites();
22092
22093
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_out("okay.");
22094
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_eol();
22095
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 }
22096
22097 128 init_spritelists();
22098
22099 // check data
22100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(f)
22101 {
22102 128 pack_fclose(f);
22103 128 }
22104 128 clear_quest_tmpfile();
22105
22106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(!oldquest)
22107 {
22108
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(exists(tmpfilename))
22109 {
22110 delete_file(tmpfilename);
22111 }
22112 128 }
22113
22114
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if(fixffcs && combosread && mapsread)
22115 {
22116 for(int32_t i=0; i<map_count; i++)
22117 {
22118 for(int32_t j=0; j<MAPSCRS; j++)
22119 {
22120 for(int32_t m=0; m<32; m++)
22121 {
22122 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].getData()].type == cCHANGE)
22123 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
22124 }
22125 }
22126 }
22127 }
22128
22129
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
128 if(get_qr(qr_CONTFULL_DEP) && !get_bit(skip_flags, skip_rules) && !get_bit(skip_flags, skip_initdata))
22130 {
22131 29 set_qr(qr_CONTFULL_DEP, 0);
22132 29 set_bit(zinit.misc, idM_CONTPERCENT, 1);
22133 29 zinit.cont_heart=100;
22134 29 zinit.start_heart=zinit.hc;
22135 29 }
22136
22137 128 box_out("Done.");
22138 128 box_eol();
22139 128 box_end(false);
22140
22141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(!get_bit(skip_flags, skip_header))
22142 {
22143 128 memcpy(Header, &tempheader, sizeof(tempheader));
22144 128 }
22145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(!get_bit(skip_flags, skip_zinfo))
22146 {
22147 128 ZI.copyFrom(tempzi);
22148 128 }
22149
22150
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(get_bit(skip_flags, skip_maps))
22151 {
22152 map_count=old_map_count;
22153 }
22154
22155
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(get_bit(skip_flags, skip_rules))
22156 {
22157 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22158 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22159 }
22160
22161
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(get_bit(skip_flags, skip_midis))
22162 {
22163 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22164 }
22165
22166
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if( FFCore.quest_format[vZelda] < 0x210 )
22167 {
22168 4 zprint2("\n[ZQUEST CREATOR METADATA]\n");
22169
22170
1/13
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
4 switch(FFCore.quest_format[vZelda])
22171 {
22172 case 0x193:
22173 {
22174 zprint2("Last saved in ZC Editor Version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22175 }
22176 case 0x192:
22177 {
22178 zprint2("Last saved in ZC Editor Version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22179 }
22180 case 0x190:
22181 {
22182 4 zprint2("Last saved in ZC Editor Version: 1.90");
22183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22184 4 else zprint2("\n");
22185 4 break;
22186 }
22187 case 0x188:
22188 {
22189 zprint2("Last saved in ZC Editor Version: 1.88");
22190 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22191 else zprint2("\n");
22192 break;
22193 }
22194 case 0x187:
22195 {
22196 zprint2("Last saved in ZC Editor Version: 1.87");
22197 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22198 else zprint2("\n");
22199 break;
22200 }
22201 case 0x186:
22202 {
22203 zprint2("Last saved in ZC Editor Version: 1.86");
22204 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22205 else zprint2("\n");
22206 break;
22207 }
22208 case 0x185:
22209 {
22210 zprint2("Last saved in ZC Editor Version: 1.85");
22211 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22212 else zprint2("\n");
22213 break;
22214 }
22215 case 0x184:
22216 {
22217 zprint2("Last saved in ZC Editor Version: 1.84");
22218 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22219 else zprint2("\n");
22220 break;
22221 }
22222 case 0x183:
22223 {
22224 zprint2("Last saved in ZC Editor Version: 1.83");
22225 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22226 else zprint2("\n");
22227 break;
22228 }
22229 case 0x182:
22230 {
22231 zprint2("Last saved in ZC Editor Version: 1.82");
22232 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22233 else zprint2("\n");
22234 break;
22235 }
22236 case 0x181:
22237 {
22238 zprint2("Last saved in ZC Editor Version: 1.81");
22239 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22240 else zprint2("\n");
22241 break;
22242 }
22243 case 0x180:
22244 {
22245 zprint2("Last saved in ZC Editor Version: 1.80");
22246 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22247 else zprint2("\n");
22248 break;
22249 }
22250 default:
22251 {
22252 zprint2("Last saved in ZC Editor Version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22253 }
22254 }
22255 4 }
22256
22257
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(loading_tileset_flags & TILESET_CLEARMAPS)
22258 {
22259 TheMaps.clear();
22260 TheMaps.resize(MAPSCRS*1);
22261 map_count = 1;
22262 map_autolayers.clear();
22263 map_autolayers.resize(6*1);
22264 for(size_t i = 0; i < MAPSCRS; ++i)
22265 {
22266 TheMaps[i].zero_memory();
22267 }
22268 }
22269
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(loading_tileset_flags & TILESET_CLEARHEADER)
22270 {
22271 memset(Header->password, 0, sizeof(Header->password));
22272 memset(Header->minver, 0, sizeof(Header->minver));
22273 memset(Header->title, 0, sizeof(Header->title));
22274 memset(Header->author, 0, sizeof(Header->author));
22275 memset(Header->version, 0, sizeof(Header->version));
22276 Header->use_keyfile = 0;
22277 Header->dirty_password = false;
22278 cvs_MD5Context ctx;
22279 cvs_MD5Init(&ctx);
22280 cvs_MD5Update(&ctx, (const uint8_t*)"", 0);
22281 cvs_MD5Final(Header->pwd_hash, &ctx);
22282 }
22283
22284 128 return qe_OK;
22285
22286 invalid:
22287 box_out("error.");
22288 box_eol();
22289 box_end(true);
22290
22291 if(f)
22292 {
22293 pack_fclose(f);
22294 }
22295
22296 if(!oldquest)
22297 {
22298 if(exists(tmpfilename))
22299 {
22300 delete_file(tmpfilename);
22301 }
22302 }
22303
22304 return qe_invalid;
22305
22306 128 }
22307
22308 128 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc,
22309 zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata,
22310 bool report, byte qst_num, dword tilesetflags)
22311 {
22312 128 loading_tileset_flags = tilesetflags;
22313 128 const char* basename = get_filename(filename);
22314 128 zapp_reporting_add_breadcrumb("load_quest", basename);
22315 128 zapp_reporting_set_tag("qst.filename", basename);
22316
22317 128 loading_qst_name = filename;
22318 128 loading_qst_num = qst_num;
22319 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22320 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22321
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if (!is_ci())
22322 loadquest_report = report;
22323
22324 128 auto start = std::chrono::steady_clock::now();
22325 128 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
22326 128 int32_t load_ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count();
22327 128 zprint2("Time to load qst: %d ms\n", load_ms);
22328
22329 128 load_tmp_zi = NULL;
22330 128 loading_qst_name = NULL;
22331 128 loadquest_report = false;
22332 128 loading_qst_num = 0;
22333
22334 128 zapp_reporting_set_tag("qst.title", Header->title);
22335 128 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
22336
22337 128 return ret;
22338 }
22339